HTTP request, Response message format

Source: Internet
Author: User

HTTP Request message Format:

The HTTP request message consists of a request line, a request header, and a 3 part of the request body.

1, Request line

Consists of 3 parts: The request method, the URL (see note 1), and the protocol version, separated by a space

The request method includes, PUT, POST, TRACE, OPTIONS, delete, and extension methods, not all of which are implemented by all servers, and some of which are not available for security purposes even if supported

The format of the protocol version is: http/major version number. Minor version number, commonly used with http/1.0 and http/1.1

2, request the head

The request header adds some additional information to the request message, consisting of a "name/value" pair, separated by a colon between the name and the value, with each row.

Common request headers are as follows:

Request Header

Description

Host

The server address to accept the request, either IP: port number or domain name

User-agent

The application name that sent the request

Connection

Specify the properties associated with the connection, such as Connection:keep-alive

Accept-charset

Notifies the service side of the encoding format that can be sent

Accept-encoding

Notifies the server that a data compression format can be sent

Accept-language

Notifies the server which languages can be sent

There is a blank line at the end of the request header, which means that the request header ends and the request body is next, which is important and essential

3, Request body

An optional part, such as a GET request, has no request body

Get Request Example:

Example of a POST request:

HTTP Response message Format:

The HTTP response message consists of a status line, a response header, and a 3 part of the response body.

1, status line

Consists of 3 parts, namely: protocol version, Status code, status code description, separated by a space

The status code is 3 digits, the 200~299 state code indicates success, 300~399 status code refers to the resource redirection, 400~499 status code refers to the client request error, 500~599 status code refers to the server error (http/1.1 introduced an informational status code to the protocol, the range is 100 ~199)

Here are a few common examples:

tr>

description

200                    

response succeeded

302

jump, The jump address is specified by the Location property in the response header (the difference between forward and redirect in the JSP)

400

client request syntax error, cannot be recognized by server

server received request, but refused service (authentication failed)

404

request resource does not exist

500

server internal error

2, Response head

Similar to the request header, adds some additional information to the response message

Common response headers are as follows:

Response header

Description

Server

Name and version of the server application software

Content-type

The type of the response body (whether it is a picture or a binary string)

Content-length

Response Body Length

Content-charset

Encoding used by the response body

Content-encoding

Data compression format used by the response body

Content-language

Language used in response body

Response Example:

Ps:

The difference between 1,uri, url, and urn

The URI full name is uniform Resource indentifier (Uniform Resource Identity), which uniquely identifies a resource, is a common concept, and the URI consists of two main subset URLs and urns

The URL full name is uniform Resource Locator (Uniform Resource positioning), identifying the resource by describing the location of the resource

The urn full name is uniform Resource name (Uniform Resource naming), which identifies the resource by its name, regardless of where it is located, so that its urn does not change even if the location of the resource is changed

The HTTP specification takes a more generic conceptual URI as its resource identifier, but in fact, the HTTP application handles only a subset of the URI's URL

HTTP request, Response 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.