CGI to NSAPI Conversion

                                                                                                                                                                                                                                                                                                                                      Back to [Book]     [Topic]

CGI to NSAPI Conversion

The CGI environment variables are not available to NSAPI. Therefore, if you need to convert a CGI variable into an SAF using NSAPI, you retrieve them from the NSAPI parameter blocks. The following table indicates how each CGI environment variable can be obtained in NSAPI.

Keep in mind that 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.

Table 2-5 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);
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 system_version()
Sun Java System-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);
SERVER_URL protocol_uri2url_dynamic("","", sn, rq);

Labels

java java Delete
server server Delete
sun sun Delete
webserver webserver Delete
application application Delete
system system Delete
webtier webtier Delete
guide guide Delete
webserver70 webserver70 Delete
sunjava sunjava Delete
developers developers Delete
web web Delete
+nsapiguide +nsapiguide Delete
developersguide developersguide Delete
nsapi nsapi Delete
nsapidevelopersguide nsapidevelopersguide Delete
nsapiguide nsapiguide Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact