HTTP header Information Summary _ other synthesis

Source: Internet
Author: User
Tags http request local time md5 unsupported port number

This article is for a number of "HTTP request header related articles" and "http Authority Guide" book after the reading of the personal summary version, to facilitate understanding.

Typically, HTTP messages include the client's request message to the server and the server's response message to the client. The client sends a request to the server that contains the requested method, URI, protocol version, and a mime-like message structure that contains the request modifiers, customer information, and content. The server responds with a status line, which includes the version of the message protocol, the success or error code plus the containing server information, entity meta information, and possible entity content.

The HTTP protocol defines a number of ways to interact with the server, the most basic of which are 4, get, POST, put, DELETE. A URL address is used to describe a resource on a network, and the Get, post, put, and delete in HTTP corresponds to the search for, change, add, delete 4 operations on this resource, and the most common of us is got and post. Get is typically used to obtain/query resource information, and post is typically used to update resource information.

An interpretation of HTTP header information

The HTTP header fields include a common header, a request header, a response header, and an entity header four parts. Each header field consists of a domain name, a colon (:), and a field value of three parts.

The common head is a head that can be used by both the client and the server, and can provide some very useful common features, such as date headers, between clients, servers, and other applications.

The request headers are specific to the request message, and they provide the server with additional information, such as what type of data the client would like to receive, such as the accept header.

The response head makes it easier for clients to provide information, such as what type of server the customer is interacting with, such as the server's head.

The entity head refers to the head that is used to deal with the body part of the entity, for example, the entity head can be used to describe the data type of the entity body part, such as Content-type head.

HTTP Universal Headers

The Common header field contains the header fields supported by both the request and response messages, and the Common header field contains the cache head Cache-control, pragma and informational header connection, Date, transfer-encoding, Update, Via.

 1, Cache-control

CACHE-CONTROL Specifies the caching mechanism that the request and response follow. Setting Cache-control in a request message or in a response message does not modify the caching process during another message handling process. The cache directives requested include No-cache, No-store, Max-age, Max-stale, Min-fresh, only-if-cached, and the instructions in the response message include public, private, No-cache, no- Store, No-transform, Must-revalidate, Proxy-revalidate, Max-age. The instructions in each message have the following meanings:

No-cache: Indicates that a request or response message cannot be cached, and can actually be stored in a local cache, but is not available to the client until the original server is validated for freshness.

No-store: Caching should remove all traces of the document from storage as soon as possible, as it may contain sensitive information.

Max-age: Cache can not return the cache time longer than the max-age specified seconds of the document, if not exceeding the specified second browser will not send the corresponding request to the server, the data is directly returned by the cache, more than this time to determine whether the server is to return new data or still provided by the cache. If the Max-stale directive is also sent, the usage period may exceed its expiration time.

Min-fresh: The document should remain fresh for at least the next set of seconds, accepting a cached object whose freshness is greater than the sum of its current age and Min-fresh values.

Max-stale: Instructs the client to receive an expired response message, and if the value of the Max-stale message is specified, the client can receive a response message that is overdue but within the specified value.

Only-if-cached: The client will get a copy only if there is a replica in the cache.

Public: Indicates that the response can be cached by any buffer and can be used to respond to any user with cached content.

Private: Indicates that the entire or partial response message for a single user cannot be treated with a shared cache and can only respond to the user who previously requested the content with the cached content.

  2, Pragma

The Pragma header field is used to contain implementation-specific instructions, most commonly pragma:no-cache. In the http/1.1 protocol, it has the same meaning as Cache-control:no-cache.

 3, Connection

Connection indicates whether a persistent connection is required. If the servlet sees the value here as "keep-alive" or if it sees that the request uses HTTP 1.1 (HTTP 1.1 By default for persistent connections), it can take advantage of the persistent connection, when the page contains multiple elements (such as applets, pictures), Significantly reduce the time required for downloading. To do this, the servlet needs to send a content-length header in the answer, the simplest way to do this is to write the content to Bytearrayoutputstream, and then calculate its size before the content is formally written out.

Close: Tell the Web server or proxy server to disconnect after completing the response to this request, and do not wait for subsequent requests for this connection.

Keepalive: Tell the Web server or proxy server to stay connected and wait for subsequent requests for this connection after completing the response to this request.

Keep-alive: If the browser requests to remain connected, the header indicates how long (in seconds) you want the WEB server to remain connected, such as keep-alive:300.

  4. Date

The Date header field represents the time when the message was sent, and the server response contains the head, because the cache is used to evaluate the freshness of the response, and the descriptive format of the time is defined by RFC822. For example, Date:mon, Dec 2001 04:25:57 GMT. When the time represented by the date represents the world standard, it is converted to local time and needs to know the time zone in which the user is located.

  5, Transfer-encoding

The WEB server indicates how it encodes the response message body (not the object in the message body), such as whether it is chunking (chunked), for example: transfer-encoding:chunked

  6, Upgrade

It can specify another protocol that may be completely different, such as a http/1.1 client can send a http/1.0 request to the server containing an update header with a value of "http/1.1" so that the client can test whether the server also uses http/1.1.

  7, Via

Lists requests from client to OCS or in the opposite direction through which proxy servers they send with what protocol (and version).

When a client request arrives at the first proxy server, the the server adds the VIA header to its own request and fills in its own information, and when the next proxy server receives a request from the first proxy, it copies the request via head of the previous proxy server in the request that it sends. and add their own information to the back, and so on, when OCS received a request from the last proxy server, check the Via head to know the route that the request was routed through. For example: via:1.0 236-81.d07071953.sina.com.cn:80 (SQUID/2.6.STABLE13)

HTTP request Headers

The request header is used to indicate who or what is sending the request, where the request originated, or the client's preferences and capabilities. The server can try to provide better response to the client based on the client information given by the requested header. The Request header field may contain the following fields Accept, Accept-charset, accept-encoding, Accept-language, Authorization, from, Host, If-modified-since, If-match, If-none-match, If-range, If-range, If-unmodified-since, Max-forwards, Proxy-authorization, Range, Referer, User-agent. The extension of the Request header field requires both communication support, and if an unsupported request header field exists, it will normally be treated as an entity header domain.

  8, Accept

Tells the Web server what type of media it accepts, */* represents any type, type/* represents all subtypes under that type, Type/sub-type.

  9, Accept-charset

The browser tells the server what character set it can receive.

  10, Accept-encoding

The browser declares its own received encoding method, usually specifying the compression method, whether compression is supported, and what compression method (Gzip,deflate) is supported.

  11, Accept-language

The browser declares the language it receives. The difference between language and character set: Chinese is a language, there are many characters in Chinese, such as BIG5,GB2312,GBK and so on.

  12, Authorization

When a client receives a www-authenticate response from a Web server, the header is used to respond to its own authentication information to the Web server.

  13, If-match

If the object's ETag does not change, it means that the object has not changed to execute the requested action and get the document.

  14, If-none-match

If the object's ETag changes, it also means that the object has changed to perform the requested action and get the document.

  15, If-modified-since

If the requested object is modified after the time specified by the header, the requested action is performed (such as returning the object), otherwise the code 304 is returned, telling the browser that the object has not been modified. Example: If-modified-since:thu, APR 2008 09:14:42 GMT

  16, If-unmodified-since

If the requested object is not modified after the time specified by the header, the requested action is performed (for example, the returned object).

  17, If-range

The browser tells the WEB server that if the object I requested does not change, give me the missing part, and if the object changes, give me the whole object. The browser lets the WEB server know whether the object has changed by sending the request object's ETag or the last modification time it knows. Always used with Range headers.

  18, Range

browsers, such as Flashget multithreaded downloads, tell the WEB server what part of the object you want to take. For example: range:bytes=1173546

  19, Proxy-authenticate

The proxy server responds to the browser and requires it to provide proxy authentication information.

  20, Proxy-authorization

The browser responds to proxy authentication requests and provides its own identity information.

  21, Host

The client specifies the domain/IP address and port number of the Web server that you want to access. such as Host:rss.sina.com.cn

  22, Referer

The browser indicates to the Web server that it is from which URL to get clicked on the URL in the current request/url, for example: referer:http://www.jb51.net

23, User-agent

The browser indicates its identity (what kind of browser it is). For example: user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; zh-cn;rv:1.8.1.14) gecko/20080404 firefox/2.0.0.14

 HTTP response Headers

The response header provides some additional information to the client, such as who is sending the response, the responder's function, or even some special instructions related to the response. These headers help the client handle the response and initiate a better request in the future. The Response header field contains age, Location, proxy-authenticate, Public, Retry-after, Server, Vary, Warning, Www-authenticate. The extension of the Response header field requires both communication support and, if an unsupported response header field exists, it will normally be treated as an entity header domain.

  24, age

When the proxy server responds to the request with its own cached entity, the header is used to indicate how long it has elapsed since the entity was created.

  25, Server

The WEB server shows you what software and version information it is. Example: server:apache/2.0.61 (Unix)

  26, Accept-ranges

The Web server indicates whether it accepts a request to get part of one of its entities, such as part of a file. Bytes: Accept, none: means not accepted.

  27, Vary

The Web server uses the contents of the header to tell the Cache server what conditions can be used to respond to subsequent requests with the object returned by this response. If the source Web server receives the first request message, the head of its response message is: Content-encoding:gzip; Vary:content-encoding, then the cache server analyzes the head of the subsequent request message, checks its accept-encoding, whether it is consistent with the Vary header value of the previous response, that is, whether the same content encoding method is used, This will prevent the cache server with its own cache inside the compressed entity response to the browser does not have the ability to decompress. For example: Vary:accept-encoding.

 HTTP Entity Headers

The entity header provides a wealth of information about the entity and its contents, from information about the object type to the various valid request methods that can be used on the resource. In short, the entity head can tell the receiver what it is dealing with. Both the request message and the response message can contain entity information, and the entity information is generally composed of the entity header domain and the entity. The Entity header field contains the original information about the entity, and the entity header includes informational head allow, Location, content head content-base, content-encoding, Content-language, Content-length, Content-location, Content-md5, Content-range, Content-type, Cache head ETag, Expires, Last-modified, Extension-header.

  28, Allow

Which request methods are supported by the server (such as Get, post, and so on).

  29, Location

Indicates where the customer should go to extract the document to locate the receiving end on the resource's location (URL). Location is not usually set directly, but through the HttpServletResponse Sendredirect method, which sets the status code to 302.

  30, Content-base

The underlying URL to use when resolving relative URLs in the body.

  31, Content-encoding

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

  32, Content-language

The WEB server tells the browser the most appropriate natural language to use when understanding the subject.

 33, Content-length

The Web server tells the browser the length or size of the object it responds to, for example: content-length:26012

  34, Content-location

Where the resources are actually located.

 35, CONTENT-MD5

The MD5 checksum of the main body.

  36, Content-range

The entity header is used to specify the insertion position of a portion of the entire entity, and he also indicates the length of the entire entity. When the server returns a partial response to the customer, it must describe the scope of the response coverage and the entire entity length. General format: Content-range:bytes-unitspfirst-byte-pos-last-byte-pos/entity-legth. For example, the form of a 500-byte secondary field for the transport header: content-range:bytes0-499/1234 If an HTTP message contains this section (for example, a response to a range request or a range of overlapping requests), Content-range represents the range of the transfer, Content-length represents the actual number of bytes transferred.

  37, Content-type

The WEB server tells the browser what type of object it responds to. For example: Content-type:application/xml

  38, Etag

is an object (such as URL) of the flag value, in terms of an object, such as an HTML file, if modified, its etag also will not modify, so, etag role and last-modified, mainly for the Web server to determine whether an object has changed. For example, when you request an HTML file the previous time, with its ETag, when this time the file is requested, the browser sends the previously obtained ETAG value to the Web server, and the Web server compares the ETag to the current ETag of the file and then knows if the file has changed.

  39, Expires

The Web server indicates when the entity will expire, and for expired objects, it can be used to respond to a customer request only after verifying its validity with the Web server. It's http/1.0 's head. Example: Expires:sat, May 2009 10:02:12 GMT

  40, Last-modified

The Web server considers the object's last modification time, such as the last modification time of the file, the last generation time of the dynamic page, and so on. Example: Last-modified:tue, May 2008 02:42:43 GMT

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.