curl command return http/1.1 406 not acceptable error

12,657

Solution 1

In some case I had, faking the agent solved this problem, by using:

curl -A "Mozilla/4.0"

Similarly using libcurl C-API:

curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0");

Solution 2

From the HTTP/1.1 standard:

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

Unless it was a HEAD request, the response SHOULD include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can choose the one most appropriate.

So drop the --head and you should see whats wrong.

The 406 may just be what is proving you right - the server doesn't support compression. :)

Share:
12,657
clickme please
Author by

clickme please

انواع هدیه تبلیغاتی شامل فلش مموری تبلیغاتی، خودکار تبلیغاتی، پاور بانک تبلیغاتی، هارد اکسترنال تبلیغاتی، ست هدیه مدیریتی تبلیغاتی، ساعت تبلیغاتی، لیوان و ماگ تبلیغاتی، ابزار تبلیغاتی، جاکلیدی تبلیغاتی، کیف و ساک تبلیغاتی، جای کارت تبلیغاتی، کلاه تبلیغاتی، هدایای خاص تبلیغاتی و دهها نوع متنوع دیگر در هدایای تبلیغاتی رادان

Updated on June 05, 2022

Comments

  • clickme please
    clickme please almost 2 years

    I am using below command line curl for knowing if my site supports compressing and caching

    curl --head --compress http://www.mysite.com

    it returns the following result

    Http://1.1 406 Not Acceptable
    Date: Wed, 28 Dec 2011 07:41:32 GMT
    Server: Apache
    Content-Type: text/html; charset-iso-8859-1
    

    what do you think about the problem? Thanks

  • clickme please
    clickme please over 12 years
    when i drop the --head it shows me the following lines <html></head> <title>406 not acceptable </title> </head></body> <h1>not acceptable</h1> . . i am using utf-8 characters in title and h1 tag too
  • Jory Geerts
    Jory Geerts over 12 years
    I thought it would show more then just that. Anyway, 406 basically means "you asked for something I can't give you". curl --compress sends Accept-Encoding: deflate, gzip - apparently your server cannot serve that. In short: This response proves that your sysadmin is wrong, the server does not support compression. You can use curl's -v flag for more verbose output, inclusing the request-headers. That may help convince your sysadmin.
  • clickme please
    clickme please over 12 years
    when i use phpinfo() for my site, it shows me this variable environment HTTP_ACCEPT_ENCODING gzip,delate
  • Brad Rippe
    Brad Rippe over 9 years
    I had to use the full agent string "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", "Mozilla/5.0" didn't work. Thanks!
  • Animal451
    Animal451 over 7 years
    The faking agent worked exactly as provided, for me. Thank you!