Http Information Header

Source: Internet
Author: User
Tags ranges unsupported

The HTTP protocol defines a number of ways to interact with the server, with 4 basic, GET, POST, PUT, DELETE, respectively. A URL address is used to describe a resource on a network, and the Get, POST, PUT, delete in HTTP corresponds to the search, change, increment, and delete 4 operations of this resource, the most common is get and POST. Get is typically used to get/query resource information, and post is typically used to update resource information.

Interpretation of HTTP header information

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

The generic header is a header that both the client and server can use to provide some useful common functionality between the client, the server, and other applications, such as the date header.

Request headers are unique to request messages, which provide some additional information to the server, such as what type of data the client wants to receive, such as the accept header.

The response header facilitates client-side information, such as what type of server the customer service is interacting with, such as the server header.

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

HTTP Generic Header

The generic header domain contains header fields that both request and response messages support, and the generic header domain contains the cache head Cache-control, pragma, and informational head connection, Date, transfer-encoding, Update, Via.

  1, Cache-control

CACHE-CONTROL Specifies the caching mechanism that requests and responses follow. Setting Cache-control in a request message or response message does not modify the caching process in another message processing process. Cache directives on request include No-cache, No-store, Max-age, Max-stale, Min-fresh, only-if-cached, directives in response messages including 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, except that it cannot be made available to clients until freshness is verified with the original server.

no-Store: The cache should remove all traces of the document from memory as soon as possible, as it may contain sensitive information.

Max-age: The cache cannot return a document that has a cache time longer than max-age specified seconds, and if not, the browser will not send the corresponding request to the server, and the data is returned directly by the cache; More than this time period is further determined by the server to return new data or still be provided by the cache. If the max-stale instruction is also sent, the usage period may exceed its expiration time.

Min-fresh: At least in the next set of seconds the document remains fresh, accepting that its fresh life is greater than its current age and the sum of the Min-fresh value of the cached object.

Max-stale: Indicates that the client can 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 expired but within the specified value.

Only-if-cached: The client obtains a copy only if a copy exists in the cache.

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

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

  2, Pragma

The pragma header domain 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 sees the request using an HTTP 1.1 (HTTP 1.1 is persistent by default), it can take advantage of the persistent connection, when the page contains multiple elements (such as applets, pictures), Significantly reduce the time it takes to download. To do this, the servlet needs to send a content-length header in the answer, and the simplest implementation is to write the content to Bytearrayoutputstream first and then calculate its size before formally writing the content.

Close: Tell the Web server or proxy server to disconnect and not wait for subsequent requests for this connection after the response to this request has been completed.

Keepalive: Tell the Web server or proxy Server, after completing the response of this request, remain connected and wait for subsequent requests for this connection.

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

  4. Date

The Date header field represents the time that the message was sent, which is included in the server response because the cache is used to evaluate the freshness of the response, and its time description format is defined by RFC822. For example, Date:mon, Dec 2001 04:25:57 GMT. The time described by date represents the world standard, which translates into 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 inside the message body), such as whether it is chunked (chunked), for example: transfer-encoding:chunked

  6, Upgrade

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

  7. Via

Lists the proxies that were sent from the client to OCS or in the opposite direction, and what protocol (and version) they used to send the request.

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

HTTP request Header

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 a better response to the client based on the client information given by the request 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. Extensions to the request header domain are supported by both parties, and if an unsupported request header domain exists, it will generally be handled as the entity header domain.

  8. Accept

Tell the Web server what type of media you accept, */* represents any type, type/* represents all subtypes under that type, Type/sub-type.

  9, Accept-charset

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

  10, Accept-encoding

  The browser affirms 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 affirms the language it receives. The difference between language and character set: Chinese is language, Chinese has many character sets, such as BIG5,GB2312,GBK and so on.

  12, Authorization

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

  13, If-match

If the ETag of an object does not change, it also means that the object has not changed before executing the requested action to obtain the document.

  14, If-none-match

If the ETag of an object changes, it also means that the object has changed to perform the requested action and obtain the document.

  15, If-modified-since

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

  16, If-unmodified-since

If the requested object has not been modified since the time specified in the header, the requested action (such as returning an object) is performed.

  17, If-range

The browser tells the WEB server that if the object I requested doesn't change, give me the missing part, and if the object changes, give me the whole object. The browser can tell the WEB server whether the object has changed by sending the etag of the requested object or the last modification time it knows. Always used with the Range header.

  18. Range

browsers, such as Flashget multi-threaded downloads, tell the WEB server what part of the object you want to take. 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 the proxy server's authentication request 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 which page URL it was from to click on the URL/url in the current request, for example: referer:http://www.ecdoer.com/

  23, User-agent

  The browser indicates its identity (which browser). 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 Header

The response header provides some additional information to the client, such as who is sending the response, the function of the responder, and 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, and Www-authenticate. The expansion of the response header field is required for both sides of the communication, and if there is an unsupported response header field, it will generally be handled as the Entity header field.

  24. Age

When the proxy server responds to a request with its own cached entity, the header is used to indicate how long the entity has been from the time it was produced to the present.

  25. Server

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

  26, Accept-ranges

The Web server indicates whether it accepts requests to obtain a portion of its entity, such as a portion of a file. Bytes: Accept, none: Indicates not accepted.

  27, Vary

The Web server uses the contents of the header to tell the Cache server under what conditions the object returned by this response responds to subsequent requests. If the source Web server receives the first request message, the header of its response message is: Content-encoding:gzip; Vary:content-encoding, the cache server parses the header of the subsequent request message and checks if its accept-encoding is consistent with the Vary header value of the previous response, that is, whether the same content encoding method is used. This prevents the cache server from responding to a browser that does not have the ability to decompress by using the compressed entity in its cache . For example: Vary:accept-encoding.

HTTP Entity Header

The entity header provides a large amount 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 summary, the entity head can tell the receiver what it is dealing with. Both the request message and the response message can contain entity information, which generally consists of entity header fields and entities. The Entity header field contains the original information about the entity, including the informative head allow, the location, the 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, etc.).

  29. Location

Indicates where the customer should go to extract the document, which is used to target the receiving end to the location (URL) of the resource. Location is usually not set directly, but by HttpServletResponse's 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. 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

The location where the resource is actually located.

  35, CONTENT-MD5

The MD5 checksum of the subject.

  36, Content-range

The entity header is used to specify the insertion position of a part 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 extent of the response coverage and the entire length of the entity. General format: Content-range:bytes-unitspfirst-byte-pos-last-byte-pos/entity-legth. For example, the transfer header is in the form of a 500-byte secondary field: content-range:bytes0-499/1234 If an HTTP message contains this section (for example, a response to a range request or an overlapping request to a range of ranges), Content-range represents the range of the transfer, The content-length represents the number of bytes actually 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 a URL) of the flag value, in terms of an object, such as an HTML file, if modified, its etag will not be modified, so, the role of the etag is similar to the role of last-modified, mainly for the Web server to determine whether an object has changed. For example, when a previous request for an HTML file, the ETag was obtained, and when the file is requested, the browser will send the previous ETag value to the Web server, and then the Web server will compare the ETag with the file's current ETag, And then we know that this file has not changed.

  39, Expires

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

  40, Last-modified

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

Http Information Header

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.