Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl command return http/1.1 406 not acceptable error

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

like image 699
clickme please Avatar asked Dec 28 '11 07:12

clickme please


People also ask

How do you fix 406 not acceptable?

The primary way to address and fix a 406 error is by checking the source code for issues in the Accept-, Request-, and Response- headers. The easiest way to review Accept- and Response- headers is to open a webpage in your browser, right-click, and select Inspect.

What does HTTP 406 Not Acceptable mean?

The HyperText Transfer Protocol (HTTP) 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers, and that the server is unwilling to supply a default representation.

What HTTP method does curl use?

By default you use curl without explicitly saying which request method to use. If you just pass in a HTTP URL like curl http://example.com it will use GET. If you use -d or -F curl will use POST, -I will cause a HEAD and -T will make it a PUT.

Does curl support HTTP?

curl supports HTTP with numerous options and variations. It can speak HTTP version 0.9, 1.0, 1.1, 2 and 3 depending on build options and the correct command line options. Using the mail reading protocol, curl can "download" emails for you. With or without using TLS.


2 Answers

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");
like image 181
Yotam Avatar answered Sep 25 '22 06:09

Yotam


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. :)

like image 31
Jory Geerts Avatar answered Sep 22 '22 06:09

Jory Geerts