Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Setting and Getting HTTP Headers

Setting and Getting HTTP Headers

You can set values for and get values of the HTTP headers.

Each of the following properties of %Net.HttpRequest contains the value of the HTTP header that has the corresponding name. These properties are automatically calculated if you do not set them:

  • Authorization

  • ContentEncoding

  • ContentLength (This property is read-only.)

  • ContentType (Specifies the Internet media type (MIME type) of the Content-Type header.)

  • ContentCharset (Specifies the charset part of the Content-Type header. If you set this, you must first set the ContentType property.)

  • Date

  • From

  • IfModifiedSince

  • Pragma

  • ProxyAuthorization

  • Referer

  • UserAgent

The %Net.HttpRequest class provides general methods that you can use to set and get the main HTTP headers. These methods ignore Content-Type and other entity headers.


Returns a string containing the main HTTP headers in this request.


Writes the main HTTP headers to the current device.


Returns the current value for any main HTTP header that has been set in this request. This method takes one argument, the name of the header (not case-sensitive); this is a string such as Host or Date


Sets the value of a header. Typically you use this to set nonstandard headers; most of the usual headers are set via properties such as Date. This method takes two arguments:

  1. The name of the header (not case-sensitive), without the colon (:) delimiter; this is a string such as Host or Date

  2. The value of that header

You cannot use this method to set entity headers or read-only headers (Content-Length and Connection).

For details, see the class documentation for %Net.HttpRequest.