|
NAMECGI::Response - Respond to CGI requests SYNOPSISSimple Interfaceuse CGI::Response qw(:Simple); print ContentType; print "<html><head>\n"; # ..... Full Interfaceuse CGI::Response; $response = new CGI::Response; $response->content_type; print $response->as_string; print "<html><head>\n"; # ..... DESCRIPTIONCGI::Response is a Perl5 module for constructing responses to Common Gateway Interface (CGI) requests. It is designed to be light-weight and efficient for the most common tasks, and also to provide access to all HTTP response features for more advanced CGI applications. There are two ways to use CGI::Response. For basic applications, the Simple Interface provides a number of plain functions that cover the most commonly-used CGI response headers. More advanced applications may employ the Full Interface object methods to access any HTTP header, or to add experimental or non-standard headers. Both interfaces try to generate reasonable defaults whenever possible. For efficiency, just the Simple Interface functions are compiled on start-up. Full Interface methods are compiled only when they are called. This helps to make CGI::Response usable in a variety of applications. [See SelfLoader for more information.] Simple InterfaceThe Simple Interface methods are not exported by default. In order to use them, you must import them explicitly. You can import all of the methods at once by saying: use CGI::Response qw(:Simple); Or, you can import just one function by listing it by name, as in: use CGI::Response qw(ContentType); Only one Simple Interface function should be called in a response, since all of these functions terminate the response header (that is, send the blank line denoting the end of the header) immediately upon execution. If you need to use a combination of headers not provided by the Simple Interface, use the Full Interface instead. All of the Simple Interface functions force a flush on the currently-selected output channel (that is, they set "$| = 1"). This is done to prevent a common probelm in CGI scripts, where a system() or exec() call causes output before the response header, and generates a server error. If you do not want "$| = 1", you should either set it back to 0 after using the Simple Interface, or you should employ the Full Interface, which does not have this side effect. For reference, below is a list of the headers sent by each function, and the default header values, if any. Arguments are listed in the order they should appear. Square brackets ([]) indicate optional arguments; angled brackets (<>) indicate required arguments. Function Argument(s) Header(s) Default(s)
-------- ----------- --------- ----------
&ContentType [content-type] Content-Type text/html
&Redirect <Location/URI> Location [none]
[permanent?] URI [none]
Content-Type text/html
Status 302 Moved Temporarily
&NoCache [content-type] Content-Type text/html
Pragma no-cache
Expires [now]
&NoContent Status 204 No Content
Each of these functions is documented more completely below, and examples for each are provided.
Full InterfaceThe Full Interface is still under development and is not currently documented. DEPENDENCIESSEE ALSOCGI::Base(3pm), CGI::BasePlus(3pm), CGI::Request(3pm), CGI::Lite(3pm), CGI(3pm), CGI::Form(3pm), LWP(3pm), SelfLoader(3pm) NOTESPlease note that future versions are not guaranteed to be backwards-compatible with this version. The interface will be frozen at version 0.1 (first beta release). VERSIONVersion: 0.03 (alpha release) Release date: 02 December 1995 AUTHORMarc Hedlund <hedlund@best.com> Copyright 1995, All rights reserved
|