curl command return http/1.1 406 not acceptable error

一个人想着一个人 提交于 2019-12-04 00:31:17

问题


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


回答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");



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



来源:https://stackoverflow.com/questions/8653271/curl-command-return-http-1-1-406-not-acceptable-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!