"HTTP request message and HTTP response message" In-depth nginx

Source: Internet
Author: User

HTTP Request message

This is necessary to understand, at least we need to know when Nginx provides HTTP services, the client will pass something. What the client sends in an HTTP request is called an HTTP request message.

1. The request line contains:

Request method, request Url,http protocol and version. The requested method and supported protocol versions include the following:
Get,head,post they all support http1.0/1.1.
Put,delete,connect,options,trace,patch they only support HTTP1.1.

2. Request the head:

Some of the information that the client attaches to the server when it passes the request, consists of key/value, key and value separated by colons, one pair per line, and the common key for the request header is Cookie,user_agent, accept-encoding.

3. Request Body:

It is usually submitted by the Post method, which may be a picture, a file, or a string.

1.2 HTTP response Messages           It's still important to know that the client gets what it wants (sometimes it may not get it, such as a service exception) and what it contains. The content returned to the client after the HTTP request is called an HTTP response message.

The HTTP response message (the content that the server returns to the client) consists of three parts, namely the response line, the response header, and the response body.

The response line contains the HTTP protocol version, the status code, and the status code description.

Where the status code is categorized as follows:

status code

                         ,         &NB Sp       Action

1XX

It indicates that the request has been accepted and is continuing processing, which is a temporary response and does not return the response body.

2XX

Successfully processed and returned, It indicates that it has been received, known, and processed within the server.

3XX

redirection function, Informs the client that it needs to continue to perform the request before it can complete.

4XX

There was a problem, and the client had a relationship, For example, 401 represents a permission problem, and 404 means that a nonexistent URL is accessed.

5XX

There was a problem with the server, For example, 500 indicates an internal error, and 504 means the request timed out.

The response header, which attaches additional information to the response message, is similar to the request header. The difference is that it is returned to the client, and the request header is initiated from the client. A common response header key such as content-type,content-encoding.

The response body, requesting body data to be returned to the client.

The following is an example of a complete response message:

The response message is not only the Nginx backend server can be sent, and sometimes nginx can be used as a server to respond to the content of the request message, such as Return,echo instructions.

"HTTP request message and HTTP response message" In-depth nginx

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.