Headers

HTTP request and response headers are handled by the classes RHTTPHeaders and THTTPHdrVal . Calling GetHeaderCollection() on RHTTPRequest and RHTTPResponse objects returns the RHTTPHeaders for the HTTP request and HTTP response respectively.

RHTTPHeaders represents the entire message header, that is, the entire set of header fields in a request or a response. THTTPHdrVal represents a value that a single header field can take.

HTTP will set some header fields automatically. The client is not required to add the following to requests:

  • Content-Length: This is derived from the client's request MHTTPDataSupplier .

  • Connection: This is handled automatically to manage a HTTP/1.1 persistent connection. If a client wants to indicate that the persistent connection is to close, it must add a Connection header.

  • Host: This is taken from the client's request URL. If a relative URL is supplied, the client must add a Host header.

  • Transfer-Encoding: This is added automatically if the client's request MHTTPDataSupplier specifies an unknown overall data size.

  • Authorisation: This is added automatically by the Authentication filter.

Also, HTTP's filters and protocol handler deals automatically with some headers contained in the server response. These are:

  • Content-Length: This value is provided through the response body MHTTPDataSupplier .

  • Connection: This is handled automatically to manage the HTTP/1.1 persistent connection.

  • Location: This is handled automatically by the Redirection filter.

  • Transfer-Encoding: This is handled automatically by the protocol handler, and 'chunked' encodings are removed before presenting the response body to the client.

  • WWW-Authenticate: This is added automatically by the Authentication filter.