19. HTTP Headers
Contents:
HTTP headers are used to transfer all sorts of information between client and server. There are four different categories of headers:
General headers and entity headers are the same for both the server and client. All headers in HTTP messages contain the header name followed by a colon (:), then a space, and the value of the header. Header names are case-insensitive (thus, Content-Type is the same as Content-type.). The value of a header can extend over multiple lines by preceding each extra line with at least one space or tab. This chapter covers the most recent draft of the HTTP 1.1 specification that was available at publication time (draft 7), as well as some headers not in the spec but which are in common use regardless. 19.1 General HeadersGeneral headers are used in both client requests and server responses. Some may be more specific to either a client or server message. Cache-ControlCache-Control: directives Specifies caching directives in a comma-separated list. Cache request directives
Cache response directives
ConnectionConnection: options Specifies options desired for this connection but not for further connections by proxies. The close connection option signifies that either the client or server wishes to end the connection (i.e., this is the last transaction). DateDate: dateformat Indicates the current date and time. The preferred date format is RFC 1123. For example:
Mon, 06 May 1996 04:57:00 GMT For backwards compatibility, however, the RFC 850 and ANSI C asctime() formats are also acceptable:
Monday, 06-May-96 04:57:00 GMT Mon May 6 04:57:00 1996 MIME-VersionMIME-Version: version Specifies the version of MIME used in the HTTP transaction. If a message's entity-body does not conform to MIME, this header can be omitted. If the transaction involves MIME-encoded data, but this header is omitted, the default value is assumed to be 1.0. Pragma: no-cachePragma: no-cache Specifies directives to a proxy system. This header is ignored by the target server. HTTP defines one directive for this header: no-cache. In HTTP 1.0, this tells the proxy to request the document from the server instead of the local cache. HTTP 1.1 prefers using Cache Control: no-cache instead. Transfer-EncodingTransfer-Encoding: encoding_type Indicates what type of transformation has been applied to the message body for safe transfer. Currently only the chunked encoding type is defined by HTTP. UpgradeUpgrade: protocol/version Specifies the preferred communication protocols. Used in conjunction with response code 101 Switching Protocols. For example:
Upgrade: HTTP/1.2 ViaVia: protocol host [comment] ... Used by gateways and proxies to indicate the protocols and hosts that processed the transaction between client and server. |
|