Skip to content

Instantly share code, notes, and snippets.

@zxhfighter
Last active December 28, 2015 04:59
Show Gist options
  • Save zxhfighter/7446227 to your computer and use it in GitHub Desktop.
Save zxhfighter/7446227 to your computer and use it in GitHub Desktop.
http 406 error

HTTP的406错误

经常和HTTP协议的200,50X,302,404等状态码打交道,这次在使用一个Flash上传控件,上传文件时,在ie下遇到了406。

具体情况描述如下:

chrome可以正常上传,之后接受响应的JSON对象;而ie则返回406(火狐则302重定向了)。

对比两次请求,发现请求头的accept参数不一样,chrome下为*/*,而ie下为text/*,后台框架(spring mvc)处理响应时,默认不支持text/*类型,从而导致了406。

通俗一点说,我只能处理A类型的东西,你给我传过来吧,但你哪儿没有,于是给我返回个406说明情况。

这里也有关于accept参数的详细说明:

If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response.

解决方案为,后台添加对text/*类型的支持。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment