Detailed Http request parameters

The HTTP Request Header Information

 

1, HTTP request method

In the following table:

 

Description:

The main use of the "GET" and "POST".

Example:

POST /test/tupian/cm HTTP/1.1

Divided into three parts:

(1) POST: HTTP request method

(2) / test / tupian / cm: the address of the Web server requests the directory (or instructions)

(3) HTTP / 1.1: URI (Uniform Resource Identifier, Uniform Resource Identifier) ​​and version

Remarks:

In Ajax, the corresponding method attribute set.

 

2、Host

Description:

web domain name server address requests

 

3、User-Agent

Description:

For more information about the type of browser HTTP client runs. By this header information, web server may determine whether the client browser type current HTTP request.

Example:

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11

 

4、Accept

Description:

Content type of the client to receive the content type in the order of priorities that the client receives.

E.g:

Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,  */*  常用;q=0.5

Remarks:

In Prototyp (1.5) Ajax code package, the Accept default setting is "text / javascript, text / html, application / xml, text / xml, * / *". This is because the default Ajax Json data acquisition mode returned by the server.

In Ajax code, you can use the XMLHttpRequest object setRequestHeader function method to dynamically set the Header information.

 

5、Accept-Language

Description:

Specifies the HTTP client browser to return to the language used to display information preference.

Example:

Accept-Language: zh-cn,zh;q=0.5

The default here is Chinese.

 

6、Accept-Encoding

Description:

Specify the client browser to support web server returns the content compression encoding type. Representation allows the server to send the output to the client before the content is compressed to conserve bandwidth. The return compression format set here is that the client browser is capable of supporting.

Example:

Accept-Encoding: gzip,deflate

Remarks:

In fact, Baidu many product lines, apache before the page is returned to the client data, the data is compressed in gzip format.

 

7、Accept-Charset

Description:

The browser can accept character encoding.

Example:

Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7

 

8、Content-Type

Description:

Show this HTTP request submitted by content type. Generally only when the post submission need to set the property. (Get can)

Example:

Content-type: application/x-www-form-urlencoded;charset:UTF-8

For Content-Type attribute value can encode the following two types:

(1) "application / x-www-form-urlencoded": encoding type when the form data used by the server, the default value is the default "application / x-www-form-urlencoded". However, in a lot of text sent to the server, which is very low coding efficiency when text or binary data contains non-ASCII characters.

(2) "multipart / form-data": when the file upload, type of encoding used should be "multipart / form-data", it can either send the text data, binary data are also supported on the carrier.

When the data submission is alone, you can use "application / x-www-form-urlencoded"; when the file is submitted, it is necessary to use "multipart / form-data" encoding type.

Or specify the submission of the Content-Type charset property which character encoding. Generally not set, it just tells what character encoding used in the data submitted by the web server post.

In the development process in general, it is a front-end engineering and back-end UI engineer what character encoding format to use to post a good discussion submitted, then the back-end ui engineer a fixed character encoding to parse the data submitted. So charset set here is not much.

 

9、Connection

Description:

Indicate the need for persistent connections. If the web server to see here is "Keep-Alive", or see the request using HTTP 1.1 (HTTP 1.1 persistent connections default), it can take advantage of persistent connections, when a page contains multiple elements (eg Applet, pictures), significantly reducing the time required to download. To achieve this, web server needs to return to the client HTTP header information to send a Content-Length (return message body length) head, the easiest method is to achieve: first write the contents of ByteArrayOutputStream, then write in the official calculate its size before the content.

Example:

Connection: keep-alive

 

10、Keep-Alive

Description:

Keep-Alive display time for this HTTP connection. The client to server connection remain in effect when subsequent requests to the server appears, Keep-Alive feature prevents establish or re-establish the connection.

Before the stop is connected to the HTTP request, then from the HTTP / 1.1 protocol, there is a long link, i.e. within a predetermined time Keep-Alive, the connection is not disconnected.

Example:

Keep-Alive: 300

 

11、cookie

Description:

We send all HTTP request when the cookie value, will be stored at the domain name along with the request to the web server.

 

12、Referer

Description:

Contains a URL, the starting page to access the current user requests a page from the URL representatives

 

Responses section

 

 

Original Reference bloggers connection: https://blog.csdn.net/YoungJ_Zhou/article/details/82765782

 

Guess you like

Origin www.cnblogs.com/vegetableDD/p/11594908.html