This is the first day of my participation in the August Challenge. For details, see:August is more challenging

Request way

way scenario
GET Request a file from the Web server
POST Send data to the Web server for processing
PUT Data is sent to the Web server and stored inside the Web server
HEAD Check whether an object exists
DELETE Delete a file from the Web server
CONNECT Provides support for channels
TRACE Trace path to the server
OPTIONS Example Query the performance of the Web server

Host

Specifies the server host name and port number to which the request will be sent

User-Agent

User-agent (UA) is a special string header that enables the server to identify the operating system and version, CPU type, browser and version, browser rendering engine, browser language, browser plug-in, etc. Some websites often send different pages to different operating systems and browsers by judging UA. As a result, some pages may not be displayed properly in a certain browser. However, the detection can be bypassed by masquerading UA.

Operating system id: FreeBSD

X11; FreeBSD (version no.) i386X11; FreeBSD (version no.) AMD64 Linux X11; Linux ppcX11; Linux ppc64X11; Linux i686X11; Linux x86_64 Mac Macintosh; PPC Mac OS XMacintosh; Intel Mac OS X Solaris X11; SunOS i86pcX11; SunOS sun4u Windows: Windows NT 6.1 corresponding operating system Windows 7Windows NT 6.0 corresponding operating system Windows vistaWindows NT 5.2 corresponding operating system Windows 2003Windows NT 5.1 operating system Windows xpWindows NT 5.0 operating system Windows 2000Windows ME Windows 98 encryption level identifier N: I: indicates weak security encryption. U: indicates strong security encryptionCopy the code

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

Accept

Specifies the types of content that the client can receive. The order in the content types indicates the order in which the client receives the content.

Such as:

Accept: text/xml,application/xml,application/xhtml+xml,text/html; Q = 0.9, the text/plain; Q = 0.8, image/PNG, /; Q = 0.5

Accept-Language

The accept-language request header allows the client to declare the natural Language it understands, as well as the preferred regional dialect. With Content negotiation, the server can choose one of many options to apply and use the Content-Language reply header to inform the client of its choice.

* : any language; *” stands for wildcard

; Q = (Q-factor Weighting) : This value represents precedence and is represented by relative mass value, also known as weighting.

Example:

Accept-Language: de Accept-Language: de-CH Accept-Language: en-US,en; Q = 0.5 Accept - Language: useful - CN, useful; Q = 0.8, useful - TW; Q = 0.7, useful - HK; Q = 0.5, en - US; Q = 0.3, en. Q = 0.2Copy the code

Accept-Charset

The request header is used to tell the client what type of character set it can handle. With the Content negotiation mechanism, the server can choose one of many options to apply and use the Content-type reply header to notify the client of its choice. Browsers usually don’t set this value because the default value for each content type is usually correct, but sending it is better for identification.

Example:

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

Content-Type

Media Type indicates the MIME type of the resource

In the response, the Content-Type header tells the client the Content Type of the actual returned Content. Browsers do MIME lookups in some cases that don’t necessarily follow the value of this heading;

This property is usually only required for post submission

Example:

Content-Type: text/html; charset=utf-8
Content-Type: multipart/form-data; boundary=something
Copy the code

There are three common encoding methods:

1.application/x-www-form-urlencoded

1.1: The most common method for Posting data. 1.2: Default submission mode for native forms (you can use encType to specify the submission data type). 1.3: This encoding is inefficient when sending large amounts of text, text containing non-ASCII characters, or binary data to the server

Application/X-wwW-form-urlencoded is one of the most commonly used request encoding methods, support GET/POST and other methods, all data into the form of key-value pair key1=value1&key2=value2, Special characters need to be escaped to UTF-8 numbers. For example, Spaces will become %20.

The default submission format is Application/X-wwW-form-urlencoded, and the default request body is parsed under Chrome’s Network panel. Display as formData;

The default contentType submitted as above is application/x-www-form-urlencoded, and the submitted data will be formatted as: fname=kongzhi&age=30;

If the request type is GET, the formatted string is sent to the server directly after the URL concatenation. If the request type is POST, the formatted string is sent in the HTTP Body’s Form Data.

2.multipart/form-data

When uploading a file using a form, you must specify the value of the encType property of the form as multipart/form-data. The request body is divided into parts, each part using –boundary partition;

3.application/json

In HTTP requests, ContentType is the default value application/ X-www-form-urlencoded. This encoding format is characterized by: For example, key=xxx&name=111&password=123456; In general, key-value pairs are fine, but if the parameter is a complex object, it is not appropriate to continue to use this encoding form. In this case, it is more appropriate to use application/ JSON to send the data to the server in the FORM of JSON. The advantage of JSON is that it can pass the data in the form of complex structure

Connection

Indicates whether persistent connections are required. Http1.1 defaults to persistent connections

Example:

Connection: keep-alive

Keep-Alive

Displays the keep-alive time for this HTTP connection. Keep-alive keeps the connection from the client to the server Alive. Keep-alive prevents a connection from being established or reestablished when a subsequent request to the server occurs.

In the past, HTTP requests were one-stop connections. Since HTTP/1.1, there have been persistent connections, which are not broken for a specified keep-alive period.

Example:

Keep-Alive: 300

cookie

When an HTTP request is sent, all the cookie values stored in the request domain name are sent to the Web server.

Referer

The HTTP Referer is part of the [header]. When [the browser] sends a request to the Web [server], it usually carries the Referer to tell the server which page the page is linked from, so the server can get some information to process

Responses of

Header explain The sample
Accept-Ranges Indicates whether the server supports a specified range request and what type of segmenting request Accept-Ranges: bytes
Age Estimated time (in seconds, non-negative) from the original server to proxy cache formation Age: 12
Allow A valid request for a network resource. If not, return 405 Allow: GET, HEAD
Cache-Control Tell all caching mechanisms if they can cache and what type Cache-control: no-cache
Content-Encoding The type of return content compression encoding supported by the Web server Content-Encoding: gzip
Content-Language Language of the response body Content-Language: en,zh
Content-Length The length of the response body Content-Length: 348
Content-Location Request an alternate address for which the resource can be substituted Content-Location: /index.htm
Content-MD5 Returns the MD5 value of the resource Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
Content-Range The byte position of this part of the total return body Content-Range: bytes 21010-47021/47022
Content-Type Returns the MIME type of the content Content-Type: text/html; charset=utf-8
Date The time the original server message was sent Date: Tue, 15 Nov 2010 08:12:31 GMT
ETag The current value of the entity tag of the request variable (last-Modified) is used with the HTTP header of the ETags request to determine whether the page has been Modified and should be returned