THE
NSAPI VERSUS THE
CGI INTERFACE
The CGI interface provides a simple, easy-to-use method of executing programs
from within an HTTP server. This mechanism can be used to create virtual
documents and interface with services outside the normal HTTP server. The CGI
interface has many advantages, including portability between server software,
and a large base of public domain programs and development tools designed for
its use.
OVERVIEW OF THE
LIMITATIONS OF
CGI
Despite the advantages of CGI, at times it would be more efficient to
interface and run directly within the server itself. The CGI interface
requires the server to execute a program, an operation which is very
expensive to the server's resources. If a CGI program is not run very
often, then this is not a problem. But there are many situations in
which a CGI program will be frequently accessed, and for these
situations it would be helpful to have an integrated solution.
A second limitation of the CGI interface is its inability to share
data and communications resources. When a CGI program is accessed by a
client, a new copy of the CGI program is invoked for each remote
client. If your program must access an external resource (such as an
IPC pipe to another resource), it must continually close and re-open
that resource.
A third limitation of the CGI interface is that it is designed for a
very specific purpose: returning the data to a network
navigator. This in itself is a very powerful feature, but there are
times when it would be nice to have your own custom functions perform
some aspect or even aspects of the request-response process.
Examples:
- Write a custom function which accesses an external database to
determine user passwords for the basic HTTP authentication scheme.
- Implement your own form of access control outside
authentication, a method which perhaps is not covered by the Netsite
facilities already available.
- Translates a custom document format into a format that is usable
by network navigators.
- Access an external resource such as a database to retrieve
documents.
- Handle errors in a specific way.
- Control exactly how requests or errors are logged, and where.
THE
NSAPI:
SERVER-APPLICATION
FUNCTIONS
In designing the Netsite server we have analyzed the steps an
information server performs in the course of responding to a request,
and broken down these steps into discrete classes of functions.
Internally, the Netsite server uses its own set of functions, which we
call server application functions, to implement the basic
Netsite functionality. These functions are referenced from a
configuration file.
Because of this flexibility, you may substitute your functions in
place of the Netsite functions on a global basis, or on the basis of
directory, file, or group of files. You may replace any step of the
process, or even all of them. Finally, you may create a function which
initializes a shared resource which is then inherited by all processes
of a multiprocess server (such as the UNIX server).
In addition to this power, you also have full access to the
server's internal data structures, functions, and I/O abstractions.
The I/O abstractions include those necessary to perform secure data
transfer between the network navigator and server, and access various
system facilities such as semaphores transparently.
To learn more about server application functions, read the full documentation.
Corporate Sales: 415/528-2555; Personal Sales: 415/528-3777
If you have any questions, please visit Customer Service.
Copyright © 1996 Netscape Communications Corporation