cURL: The requested URL returned error: 406

This article shows you a workaround for the 406 http status code.

curl: (22) The requested URL returned error: 406

In Arch Linux some packages in AUR can’t get installed because the upstream software developer is blocking the cURL headers on his websites which leads to the above error message.

cURL is the download tool used by makepkg which yaourt relies on. Both are the Arch Linux package builder or a package manager helper respectively. If you were not looking for workarounds for makepkg skip next two sections.

Seperate downloads

One workaround is to download the PKGBUILD and the upstream software seperately. Finally run makepkg.

yaourt -G dmg2img
cd dmg2img
wget http://vu1tur.eu.org/tools/dmg2img-1.6.4.tar.gz
makepkg -si

Permanent workaround

The other workaround makes makepkg permanently compatible with websites blocking the cURL headers. Your makepkg configuration file looks like this:

#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

Wherever cURL is used as the download tool or agent – how it is called in /etc/makepkg.conf – add the argument --user-agent "Mozilla/4.0".

DLAGENTS=('ftp::/usr/bin/curl --user-agent "Mozilla/4.0" -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl --user-agent "Mozilla/4.0" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl --user-agent "Mozilla/4.0" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

Direct usage of cURL

If you use cURL directly in your command line just add the user agent as shown in the previous section.

curl -O --user-agent "Mozilla/4.0" http://vu1tur.eu.org/tools/dmg2img-1.6.4.tar.gz

1 Comment

  1. The permanent user agent tweak breaks SourceForge downloads which are common in AUR. I wonder if there is another way compatible with SourceForge.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>