Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next
 

HTTP Output Reference

All Dispatcher output should be in the format of an HTTP header, followed by a blank line, followed by optional data. This section provides introductory technical information on the most common headers you will need. For detailed information about HTTP, see W3C's HTTP Protocol Area.


Content-type

The most basic HTTP header you can send is the Content-type header. For example:

   Content-type: text/html

This informs the browser what kind of output follows by giving it the Internet Media type (also called MIME type). For a list of all official MIME types, see the IANA registry. An unregistered MIME type may be used; just precede it with x-. Some of the more important types are listed in the table below.

Content-type Description
application/octet-stream Unformatted binary data.
image/gif Image in the GIF (Graphics Interchange Format) format.
image/jpeg Image in the JPEG (Joint Photographic Expert Group) format.
text/html Regular HTML (Hypertext Markup Language).
text/plain Preformatted text.
text/x-comma-separated-values Spreadsheet data.
multipart/x-mixed-replace Differently formatted blocks of data (used for Netscape server push).

Expires

Sometimes browsers will cache results when you intended for the Dispatcher to be re-invoked, and sometimes they reinvoke when it was unnecessary. Setting the Expires header gives you control over this by specifying the date/time after which the response should be considered stale. For example:

   Expires: Thu, 01 Dec 1994 16:00:00 GMT 

To mark a response as already expired, use an Expires date that is equal to or earlier than the current date. To mark a response as never expires, use an Expires date approximately one year or more from the time the response is sent. The date format should be followed exactly as above.

Location

Redirects browser immediately to a different URL. Use this as an alternative to the Content-type: header. There is no data after a header containing Location:, but you still need the blank line at the end.

   Location: http://support.sas.com

Pragma

This header informs the browser and proxy servers not to cache the results of your program, no matter what. It is similar to using the Expires: header with a date in the past but may be somewhat better supported. For example,

   Pragma: no-cache

Set-cookie

Sends a cookie to the browser to maintain client-side state. For more information, see the Netscape Cookie Spec or Cookie Central.

Format:

   Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure

For example:

   Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/cgi-bin/broker; expires=Wednesday, 09-Nov-1999 23:12:40 GMT

Next time your application is run, any matching cookies are returned in HTTP_COOKIE environment variable (use Export directive to pass to application). You will need to parse them out to retrieve the information you saved. The names and values can be anything you like, but you will need to devise a method to encode special characters such as = and ;. The date format should be followed exactly as above, with only the GMT time zone allowed, and dashes between the day, month, and year (this is different from Expires:).

Almost all newer browsers support cookies, but studies show that approximately 10% of users will disable or disallow them. Some users are concerned about the privacy considerations of using cookies. If you use cookies, be sure to explain to your users why you need them and that they should let them pass through.


Contents SAS/IntrNet 1.2: Application Dispatcher Previous Next