I. Knowledge point 1, overview
The HTTP header is divided into generic headers, request headers, response headers, and entity headers.
HTTP header structure for requester: Generic header | request Header | entity header
HTTP header structure of the responder: generic header | response Header | entity header
Accept belongs to the request header, which describes the response body data type that the client wants to receive
Content-type belongs to the entity header, which describes the body data type sent by the client
2. Accept represents the type of data that the sending side (client) wants to receive
For example: Accept:text/xml;
Represents the data type that the client wants to accept as XML type
3. Content-type represents the data type of the entity data sent by the sending side (client | server)
For example: content-type:text/html;
The data format sent on behalf of the sending side is HTML.
4. Summary
Together,
Accept:text/xml;
Content-type:text/html
This means that the data type that you want to accept is in XML format, and the data format for the data sent by this request is HTML.
Ii. Questions and Answers 1, "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, */* ", a large section of resources, in the end added */*, which is why?
My understanding: The client supports these types and specifies the priority to get the type, if not, to express the intention in turn!
2, the service side how to achieve?
My understanding:
SPRINGMVC, for example, provides a variety of messageconverter that users can expand themselves to implement
When the framework starts, it loads the various messageconverter that can be supported
When requested, according to the above settings to find whether there is a corresponding messageconverter, if found to use the found Messageconverter return the corresponding type data.
Accept and Content-type request headers for HTTP protocol