Sun Java System Web Server 7.0 Update 4 NSAPI Developer's Guide

More Complex Service() Example

The send-images function is a custom SAF that replaces the doit.cgi demonstration available on the iPlanet home pages. When a file is accessed as /dir1/dir2/something.picgroup, the send-images function checks whether the file is being accessed by a Mozilla 1.1 browser. If not, the function sends a short error message. The file something.picgroup contains a list of lines, each of which specifies a file name followed by a content-type. For example, one.gif image/gif.

To load the shared object containing your function, add the following directive at the beginning of the magnus.conf file:

Init fn=load-modules 
		shlib=your-library 
		funcs=send-images

Also, add the following line to the mime.types file:

type=magnus-internal/picgroup exts=picgroup

To execute the custom SAF during the request-response process for an object, add the following code to that object in the obj.conf file. send-images takes an optional parameter, delay, which is not used for this example.


Service method=(GET|HEAD) type=magnus-internal/picgroup fn=send-images

         

The source code for this example is in the service.c file in the install-dir/samples/nsapi directory.