Service Example
226
Netscape Enterprise Server NSAPI Programmer’s Guide • November 2001
* magnus.conf
*/
simple_msg = pblock_findval("generated-output", pb);
return REQ_PROCEED;
}
/* This is the customized Service SAF.
* It sends the "generated-output" message to the client.
*/
NSAPI_PUBLIC int simple-service(pblock *pb, Session *sn, Request
*rq)
{
int return_value;
char msg_length[8];
/* Use the protocol_status function to set the status of the
* response before calling protocol_start_response.
*/
protocol_status(sn, rq, PROTOCOL_OK, NULL);
/* Although we would expect the ObjectType stage to
* set the content-type, set it here just to be
* completely sure that it gets set to text/html.
*/
param_free(pblock_remove("content-type", rq->srvhdrs));
pblock_nvinsert("content-type", "text/html", rq->srvhdrs);
/* If you want to use keepalive, need to set content-length header.
* The util_itoa function converts a specified integer to a
* string, and returns the length of the string. Use this
* function to create a textual representation of a number.
*/
util_itoa(strlen(simple_msg), msg_length);
pblock_nvinsert("content-length", msg_length, rq->srvhdrs);
/* Send the headers to the client*/
return_value = protocol_start_response(sn, rq);
if (return_value == REQ_NOACTION) {
/* HTTP HEAD instead of GET */
return REQ_PROCEED;
}
Summary of Contents for ENTERPRISE SERVER 6.0
Page 1: ...NSAPI Programmer s Guide Netscape Enterprise Server Version6 0 November 2001...
Page 134: ...CGI to NSAPI Conversion 134 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 306: ...cinfo 306 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 312: ...Sample MIME Types File 312 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 324: ...Buffered Streams 324 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 332: ...332 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 340: ...340 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 346: ...346 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...
Page 352: ...352 Netscape Enterprise Server NSAPI Programmer s Guide November 2001...