This appendix describes how to filter input and output using a shared library provided in the Web Connector plug-in.
The gxlogcli Shared Library
Customizing Input
Customizing Output
GXDLLEXPORT int gxclientlogcallback(pblock *pb, Session *sn, Request *rq, char **pFieldArray, char *pTypeArray, char **pValueArray); GXDLLEXPORT int gxclientlogcallback(HTTP_FILTER_CONTEXT *pCtxt, PHTTP_FILTER_LOG pLog, char **pFieldArray, char *pTypeArray, char **pValueArray); GXDLLEXPORT int gxclientreqcallback(char *pInput, int len, char **pOutput); GXDLLEXPORT int gxclientheadercallback(const char* path_info, char* header, int headerLen, char* value, int valueLen, char** newHeader, char** newValue); GXDLLEXPORT int gxclientstatuscallback(const char* path_info, int *responseStatus, char* respMessage, int respSize, char** newResp); GXDLLEXPORT int gxclientpostcallback(const char* pathinfo, const char* content_type, char postHeader[], int postHeaderLen);
GXDLLEXPORT int gxclientuserheadercallback(pblock *pb, Session *sn, Request *rq, const char* path_info, const char* header, char* value, int valueLen); GXDLLEXPORT int gxclientuserheadercallback(EXTENSION_CONTROL_BLOCK *pECB, const char* path_info, const char* header, char* value, int valueLen);
Make sure you know where your #include files are located.
For Netscape Enterprise Server (NES), locate where the web server is installed (for example, NetscapeRoot). The include directory under this contains the #include files used by the stub functions. For example, the pblock.h file is in NetscapeRoot/base and the file req.h comes from NetscapeRoot/frame/req.h.
For Microsoft Internet Information Server (IIS), all the include files are under your system include directory. For example, if you have installed Msvc4.2 compiler under c:/MSDEV, then the file httpext.h is under c:/MSDEV/INCLUDE.
Add your code to the function stubs.
Compile the code using the C++ compiler provided by the platform of the Web Connector machine.
Link with any other library you are using. You need to add these library names to the makefile you are using.
Upload the code to the directory where the Web Connector binaries reside (libgxlogcli.so for Solaris and gxlogcli.dll for NT).
Restart the Web Connector plug-in.
This function is called when the Web Connector plug-in is unable to retrieve the value of a header that has been specified in the registry of the Web Connector. The function is called when the Web Connector has already tried unsuccessfully to retrieve the header from the server contextpblock for NES, HTTP_FILTER for IIS as well as access environment variables using genenv(). The purpose of gxclientuserheadercallback is to fetch the value of the header and store it in value, one of the function's parameters.
This function is used to determine how to handle post data, the data sent from the client. The parameters of this function are:
const char* pathinfo: The request string (URL) sent in by the client.
const char* content-type : The header sent in by the client.
char postHeader[]: The prefix that identifies the post data on NAS.
int postHeaderLen: The length of postHeader.
This function is called from inside gxclientlog. It collects a list of information about a request, after the request has been sent back from the Web Connector plug-in to the client. The HTTLOG parameter in the NAS registry determines what information needs to collected and stored in the log. The gxclientlogcallback function can specify additional information to be stored in the log.
pFieldArray: An array of pointers to field names that gxclientlogcallback fills in. The value should be a pointer to a null terminated ASII string.
pTypeArray: The field type specified in pFieldArray. A value of 1 indicates that the field is a string, a value of 2 indicates that the field is a number represented in ASCII format, and a value of 3 indicates that the field is contains a date or time value.
pValueArray: An array of pointers to the value of the field specified in the corresponding entry in pFieldArray.
This callback function, which controls the headers that are sent to the client, is called before returning HTTP headers back to the client. The parameters of the function are:
char* header: The header being sent to the client.
int headerLen: The number of characters in the header.
char *value: The value of the header. For example, Set-Cookie: user=Joe, Content-Type: text/html, and so on.
int valueLen: The number of characters in value.
char** newHeader: If the function is sending a new header, then newHeader contains the address of the new buffer.
char** newValue: If the function is sending a new value for the header, then newValue contains the address of the new buffer.
Every response to a client request contains only one status header with an HTTP status code. The gxclientstatuscallback function is called before the web server returns to the client the HTTP status code (int *responseStatus), which is used by the browser to determine what happened to the request. The status code is associated with an HTTP response, for example "HTTP/1.1 404 Not Found." The function allows you to modify the value of the HTTP status code, in this example 404. A status code is called only once per request.
const int *responseStatus: The response code, for example 200, 404, 500, and so on.
char respMessage: The string that describes the status of the HTTP response.
int respSize: The space available in memory for the value in respMessage.
char** newResp: The new response message.
This function controls the output sent to the client. The parameters of the function are:
char *pInput: The data being sent to the client.
int len: The number of characters in pInput.
char **ppOutput: If this callback function wishes to replace the data, then the address of the new buffer is placed here.