Request and response of HTTP protocol

Source: Internet
Author: User
Tags send cookies time and date

get/http/1.1 means to request the home page with a GET method to the server, using the http/1.1 protocol

Cache-control
Function: Used to specify the caching mechanism that response-request follows. Each instruction has the following meanings
Cache-control:public can be cached by any cache ()
Cache-control:private content is cached only in the private cache
Cache-control:no-cache All content is not cached

Accept
Role: The type of media that can be accepted by the browser side,
For example: accept:text/html represents the type of server postback that the browser can accept as text/html, which is what we often call HTML documents,
If the server cannot return data of type text/html, the server should return a 406 error (non acceptable)
Wildcard * represents any type
For example, Accept: */* on behalf of the browser can handle all types, (the general browser to the server is the issue of this)

Accept-encoding:
Function: The browser declares itself to receive the encoding method, usually specifies the compression method, whether compression is supported, what compression method is supported (Gzip,deflate), (note: This is not a character encoding);
Example: Accept-encoding:gzip, deflate

Accept-language
Role: The browser affirms the language it receives.
Language and Character set differences: Chinese is a language, Chinese has a variety of character sets, such as BIG5,GB2312,GBK and so on;
Example: accept-language:en-us

User-agent
Role: tells the HTTP server which client uses the name and version of the operating system and browser.
When we go online to the forum, often see some welcome information, which lists the name and version of your operating system, the name and version of the browser you are using, which often makes a lot of people feel very magical, in fact, The server application obtains this information from the User-agent request header domain user-agent The request header domain allows the client to tell the server about its operating system, browser, and other properties.
For example: user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; trident/4.0; CIBA;. NET CLR 2.0.50727;. NET CLR 3.0.4506.2152;. NET CLR 3.5.30729;. net4.0c; infopath.2;. NET4.0E)

Accept-charset
Role: The browser affirms its own received character set, this is the various character sets and character encodings described earlier in this article, such as gb2312,utf-8 (usually we say CharSet includes the corresponding character encoding scheme);

Cookies:
Role: The most important header, the value of the cookie is sent to the HTTP server

Content-length
Role: The length of the data sent to the HTTP server.
Example: content-length:38

Content-type
Role:
Example: content-type:application/x-www-form-urlencoded
text/html; Charset=utf-8 represents the type of the returned data, CharSet body encoding
The server uses Content-type to tell the client what type of data to respond to, so that the browser does different processing based on the type of the returned data, and if the type of the picture is displayed, the text type directly displays the content. If you use the HTML type to display content in a browser. Commonly used content-type:text/html, Image/gif, Image/jpeg, Text/plain, Text/javascript. This is the reason why you should set contenttype in ashx, try to change to Text/plain

Referer:
Role: The server that provides the context information for the request tells the server which link I have received from, such as linking to a friend from my home page, and his server is able to count the number of users who clicked the link on my page every day from the HTTP referer to visit his website.
Example: REFERER:HTTP://TRANSLATE.GOOGLE.CN/?HL=ZH-CN&TAB=WT

Transport header Field
Connection
Example: connection:keep-alive when a Web page opens, the TCP connection between the client and the server for transmitting HTTP data does not close, and if the client accesses the Web page on the server again, it will continue to use the established connection
For example: Connection:close represents the completion of a request, the TCP connection between the client and the server for transmitting HTTP data is turned off, and the TCP connection needs to be re-established when the client sends the request again.

Host (the header field is required when the request is sent)
Role: The request header domain is used primarily to specify the Internet host and port number of the requested resource, which is typically extracted from the HTTP URL
For example: We entered in the browser: http://www.guet.edu.cn/index.html
In the request message sent by the browser, the host Request header field is included, as follows:
host:http://www.guet.edu.cn
The default port number 80 is used here, and if a port number is specified, it becomes: Host: Specify port number

Cache header Field

Date
Role: The exact time and date of the message generation
Example: Date:sat, 11:35:14 GMT

Expires
Role: The browser will use the local cache for the specified expiration period
For example: Expires:tue, 2022 11:35:14 GMT

Vary
Role:
Example: vary:accept-encoding

Cookie/login header Field

P3p
Role: Used to set cookies across domains, which resolves the issue of cross-domain access to cookies for IFRAME
Example: P3p:cp=cura ADMa DEVa Psao psdo our BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR

Set-cookie
Role: A very important header, used to send cookies to the client browser, each write cookie generates a Set-cookie.
For example: set-cookie:sc=4c31523a; path=/; Domain=.acookie.taobao.com
Entity header Field

ETag
Function: Used in conjunction with If-none-match. (See examples of If-none-match in the section)
For example: ETag: "03f2b33c0bfcc1:0"

Last-modified:
Role: Used to indicate the last modification date and time of the resource. (See examples of if-modified-since in the section)
Example: last-modified:wed, Dec 09:09:10 GMT

Content-type
Role: The Web server tells the browser the type and character set of the object it responds to.
For example:
content-type:text/html; Charset=utf-8
content-type:text/html;charset=gb2312
Content-type:image/jpeg

Content-length
Indicates the length of the entity body, expressed as a decimal number stored in bytes. In the process of data downlink, content-length the way to pre-cache all the data in the server, and then all the data peremptorily to the client.
Example: content-length:19847

Content-encoding
The Web server indicates what compression method (Gzip,deflate) It uses to compress the objects in the response.
Example: Content-encoding:gzip

Content-language

Role: The Web server tells the browser to respond to the language of the object
Example: Content-language:da

Miscellaneous header Field

Server:
Function: Indicates the software information of the HTTP server
Example: server:microsoft-iis/7.5

X-aspnet-version:
Role: If the Web site is developed with ASP, this header is used to represent the version of ASP.
Example: x-aspnet-version:4.0.30319

X-powered-by:
Role: Indicates what technology the site is developed with
Example: X-powered-by:asp.net

Transport header Field

Connection
Example: connection:keep-alive when a Web page opens, the TCP connection between the client and the server for transmitting HTTP data does not close, and if the client accesses the Web page on the server again, it will continue to use the established connection
For example: Connection:close represents the completion of a request, the TCP connection between the client and the server for transmitting HTTP data is turned off, and the TCP connection needs to be re-established when the client sends the request again.

Location Header Field

Location
Function: Used to redirect a new location, including a new URL address

The HTTP protocol is a stateless and connection:keep-alive difference
Stateless means that the protocol has no memory capacity for transactions, and the server does not know what the client state is. On the other hand, there is no connection between opening a Web page on a server and the pages you have previously opened on this server

HTTP is a stateless, connection-oriented protocol, stateless does not mean that HTTP cannot maintain TCP connections, and it cannot represent HTTP using UDP protocol (no connection)

From http/1.1 onwards, the default is to open the keep-alive, to maintain the connection characteristics, in short, when a Web page opens, the client and server for the transmission of HTTP data between the TCP connection will not be closed, if the client again access to the Web page on this server, will continue to use this established connection
Keep-alive does not permanently keep the connection, it has a hold time and can be set in different server software (such as Apache) this time

Request and response of the HTTP protocol

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.