Oracle iPlanet Web Proxy Server 4.0.14 NSAPI Developer's Guide

CGI to NSAPI Conversion

When converting a CGI variable into a SAF using NSAPI, Since the CGI environment variables are not available to NSAPI, you’ll retrieve them from the NSAPI parameter blocks. The table below indicates how each CGI environment variable can be obtained in NSAPI.

Table 1–6 Parameter Blocks for CGI Variables

CGI getenv()  

NSAPI  

AUTH_TYPE

pblock_findval("auth-type", rq->vars);

AUTH_USER

pblock_findval("auth-user", rq->vars);

CONTENT_LENGTH

pblock_findval("content-length", rq->headers);

CONTENT_TYPE

pblock_findval("content-type", rq->headers);

GATEWAY_INTERFACE

"CGI/1.1"

HTTP_*

pblock_findval( "*", rq->headers); (* is lowercase; dash replaces underscore)

PATH_INFO

pblock_findval("path-info", rq->vars);

PATH_TRANSLATED

pblock_findval("path-translated", rq->vars);

QUERY_STRING

pblock_findval("query", rq->reqpb); (GET only; POST puts query string in body data)

REMOTE_ADDR

pblock_findval("ip", sn->client);

REMOTE_HOST

session_dns(sn) ? session_dns(sn) : pblock_findval("ip", sn->client);

REMOTE_IDENT

pblock_findval( "from", rq->headers);(not usually available)

REMOTE_USER

pblock_findval("auth-user", rq->vars);

REQUEST_METHOD

pblock_findval("method", req->reqpb);

SCRIPT_NAME

pblock_findval("uri", rq->reqpb);

SERVER_NAME

char *util_hostname();

SERVER_PORT

conf_getglobals()->Vport; (as a string)

SERVER_PROTOCOL

pblock_findval("protocol", rq->reqpb);

SERVER_SOFTWARE

MAGNUS_VERSION_STRING

Sun ONE-specific:

 

CLIENT_CERT

pblock_findval("auth-cert", rq->vars)

HOST

char *session_maxdns(sn);(may be null)

HTTPS

security_active ? "ON" : "OFF";

HTTPS_KEYSIZE

pblock_findval("keysize", sn->client);

HTTPS_SECRETKEYSIZE

pblock_findval("secret-keysize", sn->client);

QUERY

pblock_findval( query", rq->reqpb); (GET only, POST puts query string in entity-body data)

SERVER_URL

http_uri2url_dynamic("","", sn, rq);

Your code must be thread-safe under NSAPI. You should use NSAPI functions that are thread-safe. Also, you should use the NSAPI memory management and other routines for speed and platform independence.