|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
FastCGI: A CGI Program AcceleratorCGI programs are slowed by the fact that they need to be loaded into memory every time they are calledthat is, they begin from a standing start, every time. This startup time can be almost eliminated by using FastCGI. FastCGI acts like a second server, running next to the HTTP server and acting as the general-purpose gateway between the Web server and the CGI programs. The difference is that, in this case, the CGI programs are incorporated into the FastCGI engine, using a special FastCGI API. Thus, writing FastCGI programs is like writing programs that bind to a server API, except that here the FastCGI API is independent of the server and was designed to work in a manner similar to traditional CGI. Indeed, there are FastCGI interfaces to most servers, so that FastCGI applications are almost as portable as regular CGI programs. FastCGI was developed by Open Market Inc., but is now a free public-domain package that can be openly used and ported to any server. FastCGI programs can be written in almost any language, including perl, C, python, and Java. CGI Programming LibrariesOne of the most tedious aspects of CGI programming is parsing the environment variables or standard input datathese data are encoded, and a gateway program must decode the information before it can be used. To help in this process, a programmer can use one of the many programming libraries, available in a variety of languages, that provide routines for doing these basic tasks. Many of these have additional tools for generating HTML content for the returned document or for accessing databases. This section describes the more popular libraries of this type. You should look to the references at the end of the chapter for information about newer resources. CGI.pm: Perl 5 Librarywww-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html CGI.pm, by Lincoln Stein, is the most complete of the perl 5 CGI programming libraries. There are modules for parsing and processing form data, including those sent using the multipart/form-data encoding, for generating FORM-based HTML documents to return to the client and for error checking and report generation. The package is complicated, complete, and highly recommended. The package can be thought of as a more sophisticated (and complicated) successor to the cgi-lib.pl package (see later). However, the library is large, and thus can be slow to start upfor smaller, faster perl applications, see cgi-lite.pm. Cgic: ANSII C LibraryCgic, by Thomas Boutell, is a free (non-commercial use only) library of C-language routines for parsing and manipulating FORM data. Cgic contains modules for exception and error handling, and for handling standard processing functions, such as bounds checking and multiple-choice selection; it can even check for well-known browser errors. There is also a debugging mode. The package can run under UNIX and also under DOS/Windows. Cgi-lib.pl: Perl 4/5 Librarycgi-lib.stanford.edu/cgi-lib/ Cgi-lib.pl, by Steven Brenner, is one of the most popular perl libraries for CGI program development. It is simple, compatible with both perl 4 and 5, and can handle data sent using the multipart/form-data encoding. There are also modules for constructing standard HTML headers and footers for the returned data. Cgi-lib.pl is simpler than CGI.pm, but provides less functionality. It is also smaller and faster than CGI.pm, but not as fast as cgi-lite.pm. Cgi-lite: Perl 5 Librarywww.oasis.leo.org/perl/exts/infosys/www/cgi/ Cgi-lite.pm, by Shishir Gundavaram, is a small CGI library for processing form data. It is modeled, to some degree, after CGI.pm, but omits many of the advanced CGI.pm features. The advantage of cgi-lite.pm is speedsince it is much smaller, it is much faster to launch and is ideal when the CGI program needs to be fast. Libcgi++: C++ Librarywww.ncsa.uiuc.edu/People/daman/cgi++/ Libcgi++, by Dragos Manolescu, is a C++ library for parsing and processing data obtained from GET and POST requests. There are routines for parsing and decoding query strings, for encoding data for return to a client, and so on. UncgiUncgi, by Steven Grimm, is a simple front-end package that handles form element parsing. Uncgi decodes all the NAME and VALUE attribute values sent by GET or POST methods, and places them in environment variables. Uncgi then calls the processing program (C, perl, or whatever), passing it these environment variables. Note that this may be a problem if the string being passed in an environment variable becomes too large, since some systems place limits on the size of environment variables. Generic Web Application LibrariesThere are two additional libraries that are useful for CGI programming, but that were originally designed for writing general-purpose Web applications, such as clients (browsers or other), servers, or Web indexing robots. Libwww: W3C Sample Code LibraryLibwww is a general-purpose Web API written in C. Libwww is a highly modular, extensible API that is commonly used as the code base for Web clients and robots and for developing and testing experimental Web-based protocols and software. Libwww-perl: Library for Web Applicationswww.ics.uci.edu/pub/websoft/libwww-perl/ Libwww-perl, by Roy Fielding of the University of California at Irvine, is a perl library package of perl (Version 4 and 5) functions and provides a useful library and API for writing client and server Web applications. This package is highly recommended to any serious Web programmers. Note, however, that libwww-perl was not designed specifically for CGI programming and is not ideal for CGI applications. Development of the perl 4 package stopped in late 1994, so you should use the perl 5 version whenever possible. CGIwrap: Security WrapperAs mentioned previously, CGI programs pose a number of security risks. CGIwrap is a gateway program designed to reduce these security risks. With CGIwrap, CGI programs run with the permissions of the user who owns the program and not with those of the Web server that launches it. This makes it easier for users to write and run their own CGI programs, with reduced risk that these programs can damage other users resources. CGIwrap reduces, but does not eliminate, security problems. If you want to properly understand CGI security issues, you should read the security references listed at the end of Chapter 10. Server-Side Document ParsingThe SSI mechanism works through a parsing module incorporated into the HTTP server. Of course, it is easy to build additional modules that support other forms of parsable markup within HTML documents. Indeed, most commercial Web servers support server-side scripting via proprietary scripting languages; for example, Netscapes LiveWare suite provides JavaScript-based server-side scripting, while Microsofts Active Server Pages technology provides similar functionality on Microsoft servers.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |