[an error occurred while processing this directive]

NPH/HTTP Headers


You've probably written a CGI program or two and are aware that you must output the line "Content-Type: text/html" prior to sending a CGI generated HTML document.

This line of text is only one of many possible "HTTP Headers". Each page returned to your browser contains many headers that are provided by the web-server. Below is a simple example of what might be typically returned by a web server to your browser.

HTTP/1.0 200 OK
Date: Thursday, 31-Oct-96 17:25:32 GMT
Server: NCSA/1.3
MIME-version: 1.0
Last-modified: Wednesday, 30-Oct-96 10:12:23 GMT
Content-type: text/html
Content-length: 89

Some text on the page

A Brief Disection

Using the example from the previous topic lets perform a clinical disection of that particular server response and explain it's various components

HTTP/1.0 200 OK
Indicates that version 1.0 of the HTTP protocol will be used.
200 OK
indicates that the browser request that caused this responce was valid and excepted by the server. There are various other responce numbers which will be covered later.
Date: Thursday, 31-Oct-96 17:25:32 GMT
This is date and time when the header was produced.
Server: Apache/0.8.4
This is simply an identifier for the brand and version of the server.
MIME-version: 1.0
This indicates the version of the MIME protocol being applied in the encoding of the body of this message. The actual content type is a seperate header.
Last-modified: Wednesday, 30-Oct-96 10:12:23 GMT
This is the date that the file or resource being sent was last changed or updated.
Content-type: text/html
This is whats called a mime type, and it indicates the type of material that will be contained in the body of the message that comes after all these headers. For more information on mime types see the chapter mime types in my guide.
Content-length: 89
This is the length, measured in bytes of the all the data in the message body as messured starting immeadiatly after the blank line that seperates the headers from the message body.
A blank line indicates the end of the headers and the beginning of the message body.
Some text on the page 

Non-parsed Headers

If you want to experament with the headers, about the only way to do it is with Non Parsed Header Files. Don't get too scared, because creating an nph is incrediably simple. The trick is in the nameing of your file. Just make sure the filename begins with nph- as in... The simple fact that the filename begins with nph- means that a CGI's output is sent stright to the clients browser without the server adding any headers of it's own.

This is a double edged sword. On one hand it's both faster and more controllable than letting the server make the headers, but on the other hand, you do have to make the entire set of headers yourself.

More Cool Headers

Window-target: windowname
This header will force the document to load in the window named window_name, or if such a window does not exist, one will be created, and then the document will be loaded in it. This header has usefullness in farmes, and potentialy could be used in a multipart message to fill multiple frames with one CGI
Set-cookie: Name=Juan;
This header is used to store information in a clients browser. Later when the user returns to your pages this information will be provided in an environmental variable. Since I have an entire chapter on this subject, I'll not go into it any further here.
Cost: ???
The cost of retrieving the object is given. This is the cost of access of a copyright work. accepted.
Specification of the payment system. Format to be specified. Currently refers to an unspecified charging scheme to be agreed out of band between parties.
  • Note that ISO 4217 provides a standard for description of currency codes, but that one can imagine payment methods which have their own currency (Club Med iI believe uses cloured beads).
As "Allow" but lists those requests which anyone may use. If omitted, the default is "GET" only.
Lists the set of requests which the requesting user is allowed to issue for this URL. If this header line is omitted, the default allowed methods are "GET HEAD"
Pragma: nocache
Pragma has several options, and I'll document them all as I rediscover where I stored the docs.
Instructs the browser not to cache the content, thus guaranteeing that each time the page is called for it is read from a web-server and not from the clients hardrive.
Expires: Tues, 31 Dec 1996 23:59:59 GMT
The date after which the information in the document ceases to be valid. Caching clients, including proxies, must not cache this copy of the resource beyond the date given, unless its status has been updated by a later check of the origin server.
Referer: http://www.programatica.com/
Allows the client to specify, for the server's benefit, the address (URI) of the resource from which the request URI was obtained. This allows a server to generate lists of back-links to resources for interest, logging, optimized caching, etc. It also allows obsolete or mistyped links to be traced for maintenance.
User-Agent: Mozilla/3.0 (Win16; U)
Information about the user agent originating the request. This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations - such as inability to support HTML tables.

NPH-HTTP Responce Codes

Lets take a look at some of the responce numbers a server issues and some of the cool applications we can apply these to.

Status CODE Description Status CODE Description
100Continue 101Switching Protocols
Status CODE Description Status CODE Description
200 OK
 Ye typical responce for most pages. The normal content type for CGI generated responces in this instance is text/html
 The most likely use for this responce would be in reply to a PUT method. Such as placing a file on the server. One should no matter the reason for returning this code also include a Location: header to indicate the URL of the created resource.
202Accepted 204 No Content
This particular responce allows you to call a CGI to process a request, without that CGI causing the screen to be repainted.
Status CODE Description Status CODE Description
301Moved Permanently
 The only difference between 301 and 302 is that this one when received by a smart browser, will allow it to update it's bookmarks with an updated location.
302Moved Temporarily
This response should be followed by a Location: header. It will cause the browser to load the page whose URL is mentioned Location: in the header.
303 See Other 304 Not Modified
305 Use Proxy  
Status CODE Description Status CODE Description
400 Bad Request 401 Unauthorized
402 Payment Required 403 Forbidden
404 Not Found 405 Method Not Allowed
406 Not Acceptable 407 Proxy Authentication Required
408 Request Time-out 409 Conflict
Status CODE Description Status CODE Description
500 Internal Server Error
 The catch all error , which covers things like forgetting to output "Content-Type: txt/html" as well as your program taking a memory dump and just about anything else.
501 Not Implemented
502Bad Gateway 503Service Unavailable
504Gateway Timeout 505HTTP Version Not Supported

Send email to [email protected] for further assistance or call +507 260-6462.

Hosted By Programatica WEBDesign ®

Copyright © 1996-1997. Programatica WEB Design ®:.
All Rights Reserved Worldwide.