HTTP from getting started to being buried (5)--http message format

Source: Internet
Author: User

HTTP message Format

The HTTP message is divided into the request message and the response message, only the request message is sent, the response message will be.

The common message format is as follows:

Request message

A request message consists of four parts, namely:

    • Request Line
    • Request Header
    • Blank Line
    • Request Body
Request Line

The request line consists of three parts: the request method, the URL, and the protocol version.

GET /test/hi-there.txt HTTP/1.0

As shown above: The request line request indicates that the request method is Get,url Yes /test/hi-there.txt , the protocol version is 1.0.

Request Header

The request header is composed of multiple key-value pairs, which are generally used to describe the client and the requirements of the server, which can be said that the request header is the most important part of the HTTP protocol, and many HTTP optimizations can begin with the request header.

An article will then be devoted to the request header.

Blank Line

A blank line, after the request header, consists of a carriage return and a newline character that is used to partition the request header and the request body.

Request Body

Parameters in the request body that typically store request methods (such as Post)

Response message

The response message is also made up of four parts, namely:

    • Response Line
    • Response header
    • Blank Line
    • Response body
Response Line

The response line consists of three parts: the protocol version, the status code, and the status description.

HTTP/1.0 200 OK

As shown above, the protocol version is version 1.0, the status code is 200, the status description is OK, from this can be seen, the server successfully returned information.

Response header

The response header is similar to the request header, which describes the server information and the response to the request header.

Blank Line

A blank line, after the response header, consists of a carriage return and a newline character that is used to partition the response header and response body.

Response body

The response body is the data returned by the server for HTTP requests, which can return different kinds of data depending on the HTTP request.

HTTP from getting started to being buried (5)--http 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.