HTTP Request message Format

Source: Internet
Author: User

HTTP messages are text-oriented, and each field in the message is a number of ASCII strings, and the length of each field is indeterminate. HTTP has two types of messages: Request messages and response messages.

Request message

An HTTP request message consists of a request line, a request header (header), a blank line , and 4 parts of the request data , giving the general format of the request message.

(1) Request line

The request line consists of 3 fields of the Request Method field, the URL field, and the HTTP protocol version field, separated by a space. For example, get/index.html http/1.1.
The HTTP protocol request method has get, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, CONNECT. The most common get methods and post methods are described here.
Get: Use the Get method when the client wants to read the document from the server. The Get method requires the server to place the URL-positioned resource in the data portion of the response message, which is sent back to the client. When using the Get method, the request parameter and the corresponding value are appended to the URL, using a question mark ("?" ) represents the end of the URL and the start of the request parameter, which is limited by the length of the pass parameter. For example,/index.jsp?id=100&op=bind.

Post: You can use the Post method when the client provides more information to the server. The Post method encapsulates the request parameters in the HTTP request data, appears as a name/value, and can transmit large amounts of data.

(2) Request head

The request header consists of a keyword/value pair, one pair per line, a keyword and a value separated by a colon ":". The request header notifies the server that there is information about the client request, and the typical request headers are:

user-agent: The type of browser that generated the request.
Accept: A list of content types that the client can identify.
Host: The hostname of the request, which allows multiple domain names to be located in the same IP address as the virtual host.

(3) Blank line

The last request header is followed by a blank line that sends a carriage return and a newline character, notifying the server that the request header is no longer available.

(4) Request data

The request data is not used in the Get method, but is used in the Post method. The Post method is useful for situations where a customer needs to fill out a form.

The most commonly used request headers associated with the request data are Content-type and the Content-length .

HTTP Request message Format

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.