Adds a new HTTP header to the response. Once a record has been added to a response it cannot be removed.
Syntax
Response.AddHeader( cHeader, cValue )
Parameter
cHeader
Name of the HTTP header as character string. The name is accepted without changes but must not contain a colon. Colons are used in HTTP protocols to separate names and their values.
Even if a record of that name already exists, an additional record will be entered. An existing record can neither be deleted nor altered, even if the transfer to the client occurs only at the end of the page. Some standardized headers like the record Set-Cookie can exist multiple times.
If you add multiple records of a header that actually shouldn't exist multiple times, the consequences will depend on the browser and on the HTTP proxy servers involved. Depending on the browser the first record, the last record or a record that has been determined to be the most likely record may be used. Browsers with a strict interpretation of RFC rules could also return an error message.
The same applies for upper case and lower case notation. Whether a browser expects to see an HTTP header in the exact RFC notation or is also capable of handling different notation systems depends on the browser version used. The current browser versions no longer differentiate between upper case and lower case.
cValue
Indicates the name of the HTTP header in a character string. HTTP headers should not include line breaks; like header names, they are compulsory. The actual header determines the values that can be entered.
Note
HTTP responses are always composed of three elements – status line, header line, and data section. The data section includes the entire HTML document, the XML data or the file provided. It is the only section a user can view. Even if your browser displays the source text, all you will see is the data section.
The status line is analyzed by the browser directly to either display an error page, load a different page or display the correct response.
Frequently, HTTP headers are also called HTML headers, since generally web server products like AFP are used to return HTML data. The headers, however, refer to all data that are being returned via the HTTP protocol. This would also include downloaded files.
Headers are composed of one word consisting of letters (A-Z) and/or hyphens (-). Blanks, underscores or numerals are generally not used. Each header is assigned a value after the colon. Since each physical line corresponds to a header record, headers cannot include line breaks. A typical AFP response on the HTTP level would look like this:
HTTP/1.1 200 OK
Connection: close
Date: Tue, 04 Jan 2005 22:00:37 GMT
Server: Microsoft-IIS/6.0
Content-Type: text/html
Content-Length: 7629
Expires: Fri, 01 Jan 1999 23:00:37 GMT
<html>...
The first line is the status line. In the sample above the code 200 was returned, indicating that the request was successful. Had the page not been found the response would have been e.g. code 400.
A status line can be followed by an indefinite number of header lines. Each header corresponds to one line. Some of these header lines will be added automatically by the server, e.g. Server or Connection. Other lines like Content-Type, Content-Length or Expires are generated by AFP. You can control these through the attributes of the Response object. You may also add your own additional headers. If you always want to transmit the AFP version employed, you may use the following command line:
<%
Response.AddHeader("X-Powered-By", "AFP " + SERVER.Version())
%>
Headers starting with "X-" usually serve for information purposes only. You may define such headers without impacting potential HTTP proxies or the browser. Other headers are standardized. A description of standardized headers can be found at the official website of W3C (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
See also
Response.ContentType | Response.Header() | Response.Write()