Accept 与 Content-Type

Accept 与 Content-Type

###区别

Accept:text/xml;
Content-Type:text/html
即代表希望接受的数据类型是xml格式,本次请求发送的数据的数据格式是html

  • Accept 属于请求头, Content-Type 属于实体头

  • Accept 代表发送端(客户端)希望接受的数据类型

  • Content-Type代表发送端(客户端|服务器)发送的实体数据的数据类型

如果 accept 指定的类型和 response 返回的类型不一致,会出现 406

406:客户端无法解析服务端返回的内容

*/*的作用?

“Accept”, “image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /“,一大段资源,在最后又加上了*/*,这是为什么?

客户端支持这些类型,并指定了希望得到类型的优先级,如果没有,依次表达意愿 !