IBM AS/400E Network Router User Manual


 
arbitrary text you want to pass to your application
function. Use HTTPD_extract() to extract the text from the
INIT_STRING variable.
IP_address_template
Used only with the Service and NameTrans directives on
servers that have more than one IP address. This variable
determines if your application function is called only for
requests that comes on a specific IP address or on a range
of IP addresses.
Compatibility with other APIs
The Server API is compatible with other APIs, such as CGI. You can run your
existing CGI programs on all the servers operating systems.
Porting CGI programs
Here are a few guidelines for porting CGI applications that are written in C to use
the Server API:
1. Remove your main() entry point or rename it so you can build a service
program.
2. Eliminate global variables or protect them with a mutual exclusion semaphore.
3. Change the following calls in your programs:
v Change printf() header calls to HTTPD_set().
v Change printf() data calls to HTTPD_write().
v Change getenv() calls to HTTPD_extract(). Note, that this returns deallocated
memory, so you must free the result.
4. Remember, that the server runs in a multi-threaded environment and your
application functions must be threadsafe. If the functions are re-entrant,
performance will not decrease.
5. Do not forget to set the Content-Type header if you are using HTTPD_write()
to send data back to the client.
6. Check your code for memory leaks.
7. Think about your error paths. If you generate error messages yourself and send
them back as HTML, you should return HTTPD_OK from your service
functions.
Authentication and Authorization
Authentication is the verification of the security tokens that are associated with this
request. Authorization is the process using the security tokens to determine if the
requester has access to the resource. In the IBM HTTP Server, authentication is part
of the authorization process; it occurs only when authorization is required.
If your Server API application provides its own authorization process, it will
override the default server authorization and authentication. Therefore, if you have
Authorization directives in your configuration file, the application functions
associated with them must also handle any necessary authentication. The
predefined HTTPD_authenticate() function is provided to assist you with this.
There are three ways you can provide for authentication in your authorization
application functions:
122 Web Programming Guide V4R5