Rexx Apache External Functions

The following are the Apache functions available to the Rexx programmer. Each of these external functions is automatically available at program startup. The Rexx programmer does not have to register them before using them.



Table of Contents

General Functions

WWWAddCookie - Set a new cookie to be returned to the browser
WWWConstruct_URL - Return a URL from the specified path
WWWEscape_Path - Convert pathmame to a properly escaped URL
WWWGetArgs - Get the GET/POST request arguments
WWWGetCookies - Get the GET/POST request cookies
WWWGetVersion - Get the Mod_Rexx version string
WWWHTTP_time - Return the current RFC 822/1123 time
WWWInternal_Redirect - Create a new request from the specified URI
WWWLogError - Log an error message to the Apache log file
WWWLogInfo - Log an informational message to the Apache log file
WWWLogWarning - Log a warning message to the Apache log file
WWWRun_Sub_Req - Run an Apache subrequest
WWWSendHTTPHeader - Set the MIME content and send the HTTP header
WWWSetHeaderValue - Set a new value for an existing cookie
WWWSub_Req_Lookup_File - Run a subrequest on a filename
WWWSub_Req_Lookup_URI - Run a subrequest on a URI

Apache Request Record Functions

WWWReqRecConnection - Return the Connection Record pointer
WWWReqRecNext - Return the next request record pointer
WWWReqRecPrev - Return the previous request record pointer
WWWReqRecMain - Return the main request record pointer
WWWReqRecIsMain - Returns 1 if this is the main request
WWWReqRecThe_request - Return the request
WWWReqRecProxyreq - Returns 1 if this is a proxy request
WWWReqRecServer - Return the Server Record pointer
WWWReqRecHeader_only - Always returns 0
WWWReqRecProtocol - Returns the request HTTP protocol
WWWReqRecStatus_line - Returns/sets the status line field
WWWReqRecStatus - Returns/sets the status field
WWWReqRecMethod - Returns/sets the method field
WWWReqRecMethod_number - Returns/sets the method number field
WWWReqRecAllowed - Returns/sets the allowed field
WWWReqRecBytes_sent - Returns the bytes sent field
WWWReqRecHeader_in - Returns/sets values in the bytes headers in field
WWWReqRecHeader_out - Returns/sets values in the bytes headers out field
WWWReqRecErr_header_out - Returns/sets values in the bytes error headers out field
WWWReqRecSubprocess_env - Returns/sets values in the subprocess environment
WWWReqRecNotes - Returns/sets values in the notes
WWWReqRecContent_type - Returns/sets the content type field
WWWReqRecContent_encoding - Returns/sets the content encoding field
WWWReqRecHandler - Returns/sets the handler field
WWWReqRecContent_languages - Returns/sets the content languages field
WWWReqRecNo_cache - Returns/sets the no_cache field
WWWReqRecUri - Returns/sets the URI field
WWWReqRecFilename - Returns/sets the filename field
WWWReqRecPath_info - Returns/sets the path_info field
WWWReqRecArgs - Returns the args field
WWWReqRecFinfo_stmode - Returns the finfo stmode field
WWWReqRecUsern - Return the user login name
WWWReqRecAuth_type - Return the authentication type

Apache Server Record Functions

WWWSrvRecServer_admin - Returns the server admin email address
WWWSrvRecServer_hostname - Returns the server hostname
WWWSrvRecPort - Returns the server listening port
WWWSrvRecIs_virtual - Returns non-zero if this is a virtual server

Apache Connection Record Functions


WWWCnxRecAborted - Return 0 if a timeout occured




General Functions



WWWAddCookie

Sets a new value for an existing cookie in the returned HTTP request header.

Rexx Function Prototype


call WWWAddCookie(r, cookie_value);

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).
cookie_value
The value of the cookie. No check is performed on the validity of the cookie value. This function should be called prior to the SendHTTPHeader function.





WWWConstruct_URL

Construct a fully qualified URL from the path specified.

Rexx Function Prototype


URL = WWWConstruct_URL(r, path);

Function Parameters

escURL
The path cnverted to a fully qualified URL based on the current request record (r).
r
The Apache request handle. This is passed to the Rexx program as arg(1).
path
The filesystem pathname.





WWWEscape_Path

Takes a filesystem pathname and converts it into a properly escaped URI. If the partial flag is 0 then the function will a (/) to the beginning of the URI, otherwise a (/) will not be added.

This function does NOT convert spaces to (+) signs. This action should be performed after a call to this function.

Rexx Function Prototype


escURI = WWWEscape_Path(r, path, partial);

Function Parameters

escURI
The path cnverted to a properly escaped URL.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
path
The filesystem pathname.
partial
If the partial flage is 0 then a (/) will be added to the beginning of the returned escURL unless the path already begins with a slash(/). Otherwise a (/) will not be added.





WWWGetArgs

Returns the GET/POST request arguments.

Note: This function is NOT optional and must appear in your Rexx script.

Rexx Function Prototype


call WWWGetArgs r
/* WWWARGS.0 now contains the number of arguments */

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).

Example

The GET query string arguments or the passed POST arguments can be accessed using the following example. The name/value pairs are stored in a Rexx stem array.


call WWWGetArgs r
say 'The number of arguments is' wwwargs.0'.'
do i = 1 to wwwcookies.0
   say 'WWWARGS.'i'.NAME =' wwwargs.i.name
   say 'WWWARGS.'i'.VALUE =' wwwargs.i.value
end

Notes

Calling WWWGetArgs more than one time per Apache request can cause major problems including catastrophic errors with the Apache server. ONLY CALL WWWGETARGS ONE TIME PER APACHE REQUEST!






WWWGetCookies

Returns the cookies passed from the browser.

Rexx Function Prototype


call WWWGetCookies r
/* WWWCOOKIES.0 contains the number of cookies */

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).

Example

The cookies can be accessed using the following example. The name/value pairs are stored in a Rexx stem array.


call WWWGetCookies r
say 'The number of cookies is' wwwcookies.0'.'
do i = 1 to wwwcookies.0
   say 'WWWCOOKIES.'i'.NAME =' wwwcookies.i.name
   say 'WWWCOOKIES.'i'.VALUE =' wwwcookies.i.value
end





WWWGetVersion

Returns the Mod_Rexx module version string.

Rexx Function Prototype


version = WWWGetVersion();
/* version = "Mod_Rexx/1.01 Jun 06 2001 09:23:11" */

Function Parameters

None.






WWWHTTP_time

Returns the time/date formatted per RFC 822 and 1123.

Rexx Function Prototype


timestamp = WWWHTTP_time(r);
/* timestamp = "Tue 15 Sep 1998 14:36:31 GMT" */

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWInternal_Redirect

Creates a new request from the indicated URI and then runs it.

Rexx Function Prototype


call WWWInternal_Redirect uri, r;

Function Parameters

uri
The URI to use in creating the subrequest.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWLogError

Places a error level message in the server's error log.

Rexx Function Prototype


call WWWLogError r, message

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).
message
The message to be placed in the error log.





WWWLogInfo

Places a informational level message in the server's error log.

Rexx Function Prototype


call WWWLogInfo r, message

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).
message
The message to be placed in the error log.





WWWLogWarning

Places a warning level message in the server's error log.

Rexx Function Prototype


call WWWLogWarning r, message

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).
message
The message to be placed in the error log.





WWWRun_Sub_Req

Returns the return code from running the handlers for a subrequest.

Warning!!! During subrequest processing none of the Rexx handlers will be invoked. They will always DECLINE the request.

Rexx Function Prototype


retc = WWWRun_Sub_Req(r);

Function Parameters

retc
The return code from the subrequest.
r
The Apache subrequest handle.





WWWSendHTTPHeader

Sets the mime content-type and then sends the headers to the browser.

Note: This function is NOT optional and must appear in your Rexx script.

Rexx Function Prototype


return_code = WWWSendHTTPHeader(r, type);

Function Parameters

return_code
The return code from the Apache function
r
The Apache request handle. This is passed to the Rexx program as arg(1).
type
The content-type. Usually this will be the string "text/html"





WWWSetHeaderValue

Sets a new value for an existing cookie in the returned HTTP request header.

Rexx Function Prototype


call WWWSetHeaderValue(r, key, value);

Function Parameters

r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The header key to be replaced.
value
The value to be applied to the header key. This function should be called prior to the SendHTTPHeader function.





WWWSub_Req_Lookup_File

Returns the resulting request record pointer from a subrequest from the given filename.

Rexx Function Prototype


subrec = WWWSub_Req_Lookup_File(file, r);

Function Parameters

subreq
The subrequest record pointer
file
The filename to use in creating the subrequest.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWSub_Req_Lookup_URI

Returns the resulting request record pointer from a subrequest from the given URI.

Rexx Function Prototype


subrec = WWWSub_Req_Lookup_URI(uri, r);

Function Parameters

subreq
The subrequest record pointer
uri
The URI to use in creating the subrequest.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





Apache Request Record Functions



WWWReqRecConnection

Returns the Connection Record Pointer.

Rexx Function Prototype


connxrecptr = WWWReqRecConnection(r);

Function Parameters and Return Values

connxrecptr
The Connection Record pointer.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecServer

Returns the Server Record Pointer.

Rexx Function Prototype


srvrrecptr = WWWReqRecServer(r);

Function Parameters and Return Values

srvrrecptr
The Server Record pointer.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecNext

Returns a Request Record Pointer. This is used during subrequest processing

Rexx Function Prototype


reqrecptr = WWWReqRecNext(r);

Function Parameters and Return Values

reqrecptr
The next Request Record pointer.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecPrev

Returns a Request Record Pointer. This is used during subrequest processing

Rexx Function Prototype


reqrecptr = WWWReqRecPrev(r);

Function Parameters and Return Values

reqrecptr
The previous Request Record pointer.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecMain

Returns a Request Record Pointer. This is used during subrequest processing

Rexx Function Prototype


reqrecptr = WWWReqRecMain(r);

Function Parameters and Return Values

reqrecptr
The main Request Record pointer.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecIsMain

Returns 1 if this is the main Request Record, otherwise returns 0.

Rexx Function Prototype


retc = WWWReqRecIsMain(r);

Function Parameters and Return Values

retc
1 if this is the main request, otherwise 0.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecThe_request

Returns a copy of the request.

Rexx Function Prototype


retc = WWWReqRecThe_request(r);

Function Parameters and Return Values

retc
The request.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecProxyreq

Returns 1 if this is a proxy request, otherwise returns 0.

Rexx Function Prototype


retc = WWWReqRecProxyreq(r);

Function Parameters and Return Values

retc
1 if this is a proxy request, otherwise 0.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecHeader_only

Always returns 0 because Mod_Rexx processes header only requests.

Rexx Function Prototype


retc = WWWReqRecHeader_only(r);

Function Parameters and Return Values

retc
Always 0.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecProtocol

Returns a copy of the protocol string.

Rexx Function Prototype


retc = WWWReqRecProtocol(r);

Function Parameters and Return Values

retc
Protocol string (like "HTTP/1.0").
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecStatus_line

Returns/sets the status line returned to the browser.

Rexx Function Prototype


retc = WWWReqRecStatus_line(r [, newstatusline]);

Function Parameters and Return Values

retc
The status line.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newstatusline
The new string to be assigned to the status line field.





WWWReqRecStatus

Returns/sets the status.

Rexx Function Prototype


retc = WWWReqRecStatus(r [, newstatus]);

Function Parameters and Return Values

retc
The status.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newstatus
The new numeric value to be assigned to the status field.





WWWReqRecMethod

Returns/sets the method.

Rexx Function Prototype


retc = WWWReqRecMethod(r [, newmethod]);

Function Parameters and Return Values

retc
The method string.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newmethod
The new string to be assigned to the method ("GET", "POST", etc) field.





WWWReqRecMethod_number

Returns/sets the method number.

Rexx Function Prototype


retc = WWWReqRecMethod_number(r [, newmethodnum]);

Function Parameters and Return Values

retc
The method number.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newmethodnum
The new numeric value to be assigned to the method number field.





WWWReqRecAllowed

Returns/sets the allowed methods for the handler.

Rexx Function Prototype


retc = WWWReqRecAllowed(r [, newallowednum]);

Function Parameters and Return Values

retc
The allowed number (bit field).
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newallowednum
The new numeric value to be assigned to the allowed field.





WWWReqRecBytes_sent

Returns the number of document body bytes sent to the browser so far.

Rexx Function Prototype


retc = WWWReqRecBytes_sent(r);

Function Parameters and Return Values

retc
The number of bytes sent so far.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecHeader_in

Returns/sets incoming HTTP headers.

Rexx Function Prototype


retc = WWWReqRecHeader_in(r, key [, newvalue]);

Function Parameters and Return Values

retc
The value of the header field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The name of the header field to return/set.
newvalue
The new value to assign to the header key name.





WWWReqRecHeader_out

Sets outgoing HTTP headers.

Rexx Function Prototype


retc = WWWReqRecHeader_out(r, key, value);

Function Parameters and Return Values

retc
The value of the header field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The name of the header field to set.
newvalue
The new value assigned to the header key name.





WWWReqRecErr_header_out

Returns/sets outgoing error HTTP headers.

Rexx Function Prototype


retc = WWWReqRecErr_header_out(r, key [, newvalue]);

Function Parameters and Return Values

retc
The value of the header field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The name of the header field to return/set.
newvalue
The new value to assign to the header key name.





WWWReqRecSubprocess_env

Returns/sets subprocess environment variables.

Rexx Function Prototype


retc = WWWReqRecSubprocess_env(r, key [, newvalue]);

Function Parameters and Return Values

retc
The value of the environment field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The name of the environment variable to return/set.
newvalue
The new value to assign to the environment variable.





WWWReqRecNotes

Returns/sets process notes variables.

Rexx Function Prototype


retc = WWWReqRecNotes(r, key [, newvalue]);

Function Parameters and Return Values

retc
The value of the notes field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
key
The name of the notes variable to return/set.
newvalue
The new value to assign to the notes variable.





WWWReqRecContent_type

Returns/sets the MIME content type.

Rexx Function Prototype


retc = WWWReqRecContent_type(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the content type field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the content type field.





WWWReqRecContent_encoding

Returns/sets the content encoding.

Rexx Function Prototype


retc = WWWReqRecContent_type(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the content encoding field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the content encoding field.





WWWReqRecHandler

Returns/sets the handler.

Rexx Function Prototype


retc = WWWReqRecHandler(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the handler field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the handler field.





WWWReqRecContent_languages

Returns/sets the content languages field.

Rexx Function Prototype


retc = WWWReqRecContent_languages(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the content languages field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the content languages field.





WWWReqRecNo_cache

Returns/sets the value of the no_cache field.

Rexx Function Prototype


retc = WWWReqRecNo_cache(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the no_cache field (0 or 1).
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value (0 or 1) to assign to the no_cache field.





WWWReqRecUri

Returns/sets the request URI field.

Rexx Function Prototype


retc = WWWReqRecUri(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the URI field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the URI field.





WWWReqRecFilename

Returns/sets the request filename field.

Rexx Function Prototype


retc = WWWReqRecFilename(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the filename field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the filename field.





WWWReqRecPath_info

Returns/sets the request path_info field.

Rexx Function Prototype


retc = WWWReqRecPath_info(r [, newvalue]);

Function Parameters and Return Values

retc
The value of the path_info field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).
newvalue
The new value to assign to the path_info field.





WWWReqRecArgs

Returns the request args field.

Rexx Function Prototype


retc = WWWReqRecArgs(r);

Function Parameters and Return Values

retc
The value of the args field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecFinfo_stmode

Returns the request stat finfo field as a string of 1's and 0's.

Rexx Function Prototype


retc = WWWReqRecFinfo_stmode(r);

Function Parameters and Return Values

retc
The value of the stat finfo field.
r
The Apache request handle. This is passed to the Rexx program as arg(1).


WWWReqRecUser

Returns the user's login name.

Rexx Function Prototype


retc = WWWReqRecUser(r);

Function Parameters and Return Values

retc
The user's login name.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





WWWReqRecAuth_type

Returns the authentication method (if used).

Rexx Function Prototype


retc = WWWReqRecAuth_type(r);

Function Parameters and Return Values

retc
The authentication method.
r
The Apache request handle. This is passed to the Rexx program as arg(1).





Apache Server Record Functions



WWWSrvRecServer_admin

Returns the email address of the server administrator.

Rexx Function Prototype


retc = WWWSrvRecServer_admin(s);

Function Parameters and Return Values

retc
The server administrator email address.
s
The Apache server pointer. You can get this value from the WWWReqRecServer Rexx external function.





WWWSrvRecServer_hostname

Returns the server's hostname.

Rexx Function Prototype


retc = WWWSrvRecServer_hostname(s);

Function Parameters and Return Values

retc
The server's hostname.
s
The Apache server pointer. You can get this value from the WWWReqRecServer Rexx external function.





WWWSrvRecPort

Returns the server's listening port.

Rexx Function Prototype


retc = WWWSrvRecPort(s);

Function Parameters and Return Values

retc
The server's listening port.
s
The Apache server pointer. You can get this value from the WWWReqRecServer Rexx external function.





WWWSrvRecIs_virtual

Returns 0 if this is a virtual server.

Rexx Function Prototype


retc = WWWSrvRecIs_virtual(s);

Function Parameters and Return Values

retc
Returns 0 if this is a virtual server, otherwise returns non-zero value.
s
The Apache server pointer. You can get this value from the WWWReqRecServer Rexx external function.





Apache Connection Record Functions






WWWCnxRecAborted

Returns 1 if a timeout has occured, otherwise returns 0.

Rexx Function Prototype


retc = WWWCnxRecAborted(c);

Function Parameters and Return Values

retc
The timeout indicator.
c
The Apache connection pointer. You can get this value from the WWWReqRecConnection Rexx external function.

Valid XHTML 1.0! Copyright (C) W. David Ashley 2004. All Rights Reserved.