4.9 RES-Reach and HTTP Headers

    RES-Reach and your web server automatically add HTTP header information to your document. If you wish to override their defaults, just insert all the required header information at the beginning of the template file. If you do not want any HTTP headers, enter "No-header" as the first token in your template file.

    It is very important that your HTTP headers (or the "No-header" token) are not preceded by anything other than RES-Reach comments or whitespace, and that they are complete and correctly formatted. If you have problems creating your own headers, consult an HTTP reference for assistance.

    Examples

    Example 1: Redirection


    Location: http://www.res.ca/
    Content-type:text/html

    bye-bye

    Example 2: Authentication


    <IF VARIABLE="{HTTP_AUTHORIZATION}" OPERATOR="NE" COMPARISON="Basic Z3Vlc3Q6x">
    Status:401 Access Denied
    WWW-Authenticate: Basic realm="RES-Reach"
    Content-type:text/html

    If you made it here, then your Web server allows anonymous access or<BR>
    has already checked your userID and password.
    You tried to log in as {REMOTE_USER}<BR>
    Your Base64 encoded password is {HTTP_AUTHORIZATION}<BR>
    Try "guest" and no password
    </IF>

    <IF VARIABLE="{HTTP_AUTHORIZATION}" OPERATOR="EQ" COMPARISON="Basic Z3Vlc3Q6x">
    Content-type:text/html

    Welcome, {REMOTE_USER}!
    </IF>

    Example 3: Cookies

    <![cookie.nbt]>
    <IF VARIABLE=";{HTTP_COOKIE};" OPERATOR="SS" COMPARISON=";{Unknown};;">
    Set-cookie: type=ChocolateChip
    Content-type:text/html
    Expires: Mon, 01 Jul 1996 00:00:00 GMT

    <H1>A cookie was sent</H1>
    </IF>
    <IF VARIABLE=";{HTTP_COOKIE};" OPERATOR="NS" COMPARISON=";{Unknown};;">
    <IF VARIABLE="GingerSnap" OPERATOR="SS" COMPARISON="{HTTP_COOKIE}">
    Set-cookie: type=vanilla
    Content-type:text/html
    Expires: Mon, 01 Jul 1996 00:00:00 GMT

    </IF>
    <IF VARIABLE="GingerSnap" OPERATOR="NS" COMPARISON="{HTTP_COOKIE}">
    Set-cookie: type=GingerSnap
    Content-type:text/html
    Expires: Mon, 01 Jul 1996 00:00:00 GMT

    </IF>

    <H1>You already had a cookie</H1>
    It said: <BR>
    {HTTP_COOKIE}<BR>
    </IF>

    Example 4: Piping RES-Reach Results to an Output File.

    1. From a Windows 95 workstation connected to the RES-Reach server, open a MS-DOS Prompt window.
    2. Verify that there is a default NBT which, when RES-Reach is confronted with no template parameter, looks in the PATH_INFO environment variable for the name of the NBT.
    3. Enter the values for the REQUEST_METHOD and PATH_INFO environment variables. PATH_INFO should contain the name of a RES-Reach template which begins with the "No-header" token.
    4. 
      SET REQUEST_METHOD=GET
      SET PATH_INFO=testsuites/res-reach/normal/try
      
      
    5. Go to the server directory where bazar.exe resides and type:
      
      bazar.exe \\res12\pipe\resreach >file1
      
      
      where res12 is the name of the server.
    6. View file1 with an editor and verify that the HTTP header is NOT present.