Accept and Content-type request headers for HTTP protocol

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.