HTTP Header Learning Summary

Source: Internet
Author: User
Tags local time

In the development of HTTP requests, the HTTP header information smattering, a variety of Baidu Google to summarize the information learned.

Introduction to HTTPHTTP (hypertexttransferprotocol) is an abbreviation for Hypertext Transfer Protocol, which is used to transmit data of WWW mode, please refer to RFC2616 for details of HTTP protocol. The HTTP protocol uses the request/response model. 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 modifier, customer information, and content. The server responds with a status line that includes the version of the message protocol, success or error encoding plus the server information, entity meta information, and possible entity content. Common header fields   Cache-controlCACHE-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: Public indicates that the response can be cached by any buffer; Private indicates that the entire or partial response message for a single user cannot be shared cache processing. This allows the server to simply describe a partial response message for the user, which is not valid for another user's request; No-cache indicates that the request or response message cannot be cached; No-store is used to prevent important information from being inadvertently published. Sending in the request message will make the request and response messages do not use the cache; Max-age indicates that the client can receive a response that is not longer than the specified time (in seconds), Min-fresh indicates that the client can receive a response that is less than the current time plus the specified time ; Max-stale indicates that the client can receive a response message that exceeds the timeout period. If you specify a value for the Max-stale message, the client can receive a response message that exceeds the specified value for the timeout period. DateThe Date header field represents the time the message was sent, and the time description format was defined by RFC822. For example, Date:mon,31dec200104:25:57gmt. 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. PragmaThe 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. HostSpecifies the intenet host and port number of the requesting resource, which must represent the location of the originating server or gateway that requested the URL. The http/1.1 request must contain the host header domain or the system will return with a 400 status code; AcceptTell the Web server what type of media you accept, */* represents any type, type/* represents all subtypes under that type, Type/sub-type. Accept-charsetThe browser affirms the character set it receives. accept-encodingThe browser declares itself to receive the encoding method, usually specifies the compression method, whether compression is supported, what compression method is supported (Gzip,deflate) Accept-languageThe browser affirms the language that you receive AuthorizationWhen 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. User- AgentThe content contains the user information that made the request. RefererAllows the client to specify the source resource address of the request URI, which allows the server to generate a fallback list that can be used to log in, optimize the cache, and so on. He also allows the abolition or wrong connection to be traced for maintenance purposes. If the requested URI does not have its own URI address, Referer cannot be sent. If a partial URI address is specified, the address should be a relative address; Rangeyou can request one or more child scopes for an entity. For exampleRepresents the first 500 bytes: bytes=0-499 represents the second 500 bytes: bytes=500-999 represents the last 500 bytes: bytes=-500 represents the range after 500 bytes: bytes=500-First and last byte: bytes=0-0, 1 specify several ranges at the same time: bytes=500-600,601-999 However, the server can ignore this request header, and if the unconditional get contains a range request header, the response will be returned with a status code of 206 (partialcontent) instead of a (OK) Content-typ eused to indicate the media type of the entity to the receiver, specify the entity media type that the head method sends to the receiver, or the request media type sent by the Get method, indicating what MIME type the subsequent document belongs to. the Enctype property of a form is encoded in two common ways: application/x-www-form-urlencoded and Multipart/form-data, which are application/by default. X-www-form-urlencoded. When action is get, the browser uses x-www-form-urlencoded encoding to convert the form data into a string (Name1=value1&name2=value2 ... ), and then append the string to the URL, using the. Split, to load the new URL. When the action is post, the browser encapsulates the form data into the HTTP body and then sends it to the server. If you don't have a type=file control, you can use the default application/x-www-form-urlencoded. But if you have type=file, you will need to use Multipart/form-data. The browser splits the entire form into units of controls and adds Content-disposition (form-data or file) to each section, Content-type (default = Text/plain), name (control name), and so on. and add the separator (boundary). Content-lengthrepresents the actual number of bytes transferred. Allow entity headers to which request methods (such as Get, post, and so on) are supported by the server.   Content-rangerepresents the range of the transfer, which specifies the insertion position of a part of the entire entity, and 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, transfer the first 500 bytes in the form of a field: content-range:bytes0-499 /1234 If an HTTP message contains this section (for example, a response to a range request or overlapping requests for a range of scopes). Content-encoding refers to the encoding (Encode) method of the document. An entity can be a coded stream of bytes encoded by content-encoding or Content-type, whose length is defined by content-length or Content-range. AgeWhen 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. ETagis 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 previously obtained ETag value to the Web server, and then the Web server will compare the ETag with the file's current etag, and then know that the file has not changed The ExpiredThe 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 If-matchIf the ETag of an object does not change, it actually means that the object does not change before the requested action is executed. If-none-matchIf the ETag of an object changes, it also means that the object has changed to perform the requested action. if-modified-sinceIf 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 if-unmodified-sinceIf the requested object has not been modified since the time specified in the header, the requested action (such as returning an object) is performed. If-rangeThe 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. last-modifiedThe 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 LocationThe WEB server tells the browser that the object you are trying to access has been moved to a different location to fetch it at the location specified by the header. Example: Location:http://i0.sinaimg.cn/dy/deco/2008/0528/sinahome_0803_ws_005_text_0.gif proxy-authenticateThe proxy server responds to the browser and requires it to provide proxy authentication information. Proxy-authorization: The browser responds to the proxy server's authentication request and provides its own identity information. ServerThe WEB server indicates what software and version information it is. Example: server:apache/2.0.61 (Unix) transfer-encodingThe WEB server indicates how it encodes the response message body (not the object inside the message body), such as whether it is chunked (chunked). Example: transfer-encoding:chunked VaryThe 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 then 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, which prevents the cache The server responds to the compressed entity in its own Cache to a browser that does not have the ability to decompress. Example: vary:accept-encoding ViaLists 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 the client request arrives at the first proxy server, the server adds via header in its own request and fills in its own information, and when the next proxy receives a request from the first proxy server, it copies the Via header of the request from the previous proxy server in its own request. and add their own information to the back, and so on, when OCS receives the last Proxy server request, check Via header, know the route that the request passes. Example: via:1.0 236.d0707195.sina.com.cn:80 ConnectionRequest: Close (Tell the Web server or proxy server, after completing the response to this request, disconnect, do not wait for subsequent requests for this connection). KeepAlive (tells the Web server or proxy server, after completing the response of this request, remains connected, waiting for subsequent requests for this connection). Response: Close (the connection is closed). KeepAlive (connection is maintained, waiting for subsequent requests for this connection). Keep-alive: If the browser requests to remain connected, the header indicates how long (in seconds) you want the WEB server to remain connected. Example: keep-alive:300



From for notes (Wiz)



HTTP Header Learning Summary

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.