$webinfo: HTTP Header and Request Functions

Use the $webinfo HTTP header functions to transfer HTTP protocol information between a browser and a server.

$webinfo("HttpResponseHeaders") { = Response}

Request = $webinfo("HttpRequestHeaders")

Parameters = $webinfo("HttpRequestParams")

Parameters

Parameters

Parameter

Data Type

Description

HttpResponseHeaders

String

Returned HTTP headers, excluding cookie headers.

HttpRequestHeaders

String

Incoming HTTP headers from the browser, excluding cookie headers

HttpRequestParams

String

Incoming parameters present in the request URL

HTTPREQUESTPARAMS

The HttpRequestParams channel contains an associative list of request parameters present in the request URL; it can include the entity names and occurrence IDs that are used by websetocc to set the current occurrence for the current component.

It contains an associative list of request parameters present in the request URL:

ParameterName1 = Value1 ; ParameterName2 = Value2...

These parameters contain the entity names and occurrence IDs that are used by websetocc to set the current occurrence for the current component.

Using Response Headers for Authentication

The following example shows code for a static server page (USP) that creates a dynamic pop-up logon box in the browser using a HTTP response header.

  1. Define a component variable vLogonAttempts with a numeric data type. It records how many times the user tries to log on. If the user tries to logon 3 times with the wrong logon information, an HTTP error page is displayed.
  2. Set the State Managed by property as Cookie on the Server Page properties. This is for keeping the state of the component variable TRIES.
  3. Add code in the execution trigger of the server page, for example:
    webget
    if($user !="correct-user" | $password != "password-for-the-correct-user")
       $vLogonAttempts$=$vLogonAttempts$+1
       ; pop-up a logon box, 
       $webinfo("httpresponseheaders")="%\
          WWW-Authenticate: basic realm=%%"Administrator log-in(%%$vLogonAttempts$%%%)%%"·;%\
          Expires=0·;Cache-Control=no-cache"
       $webinfo("status")="401"
       $webinfo("statusreason")="Unauthorized"
       $webinfo("output")="<html><title>401 - Unauthorized</title>%\
          <body><h1>401- Unauthorized to view this page</h1></body></html>"
    else
       $vLogonAttempts$=0
       webgen
    endif

Note: The correct-user and the password-for-the-correct-user are only for demonstration purposes.

Related Topics