Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / module-CGIHTTPServer.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-cookielib.html" />
<link rel="prev" href="module-SimpleHTTPServer.html" />
<link rel="parent" href="internet.html" />
<link rel="next" href="module-cookielib.html" />
<meta name='aesop' content='information' />
<title>11.19 CGIHTTPServer -- CGI-capable HTTP request handler</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.18 SimpleHTTPServer "
href="module-SimpleHTTPServer.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
href="internet.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.20 cookielib "
href="module-cookielib.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-SimpleHTTPServer.html">11.18 SimpleHTTPServer </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-cookielib.html">11.20 cookielib </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION00131900000000000000000">
11.19 <tt class="module">CGIHTTPServer</tt> --
CGI-capable HTTP request handler</A>
</H1>
<P>
<A NAME="module-CGIHTTPServer"></A>
<P>
The <tt class="module">CGIHTTPServer</tt> module defines a request-handler class,
interface compatible with
<tt class="class">BaseHTTPServer.BaseHTTPRequestHandler</tt> and inherits behavior
from <tt class="class">SimpleHTTPServer.SimpleHTTPRequestHandler</tt> but can also
run CGI scripts.
<P>
<span class="note"><b class="label">Note:</b>
This module can run CGI scripts on <span class="Unix">Unix</span> and Windows systems;
on Mac OS it will only be able to run Python scripts within the same
process as itself.</span>
<P>
The <tt class="module">CGIHTTPServer</tt> module defines the following class:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-3611' xml:id='l2h-3611' class="class">CGIHTTPRequestHandler</tt></b>(</nobr></td>
<td><var>request, client_address, server</var>)</td></tr></table></dt>
<dd>
This class is used to serve either files or output of CGI scripts from
the current directory and below. Note that mapping HTTP hierarchic
structure to local directory structure is exactly as in
<tt class="class">SimpleHTTPServer.SimpleHTTPRequestHandler</tt>.
<P>
The class will however, run the CGI script, instead of serving it as a
file, if it guesses it to be a CGI script. Only directory-based CGI
are used -- the other common server configuration is to treat special
extensions as denoting CGI scripts.
<P>
The <tt class="function">do_GET()</tt> and <tt class="function">do_HEAD()</tt> functions are
modified to run CGI scripts and serve the output, instead of serving
files, if the request leads to somewhere below the
<code>cgi_directories</code> path.
</dl>
<P>
The <tt class="class">CGIHTTPRequestHandler</tt> defines the following data member:
<P>
<dl><dt><b><tt id='l2h-3612' xml:id='l2h-3612' class="member">cgi_directories</tt></b></dt>
<dd>
This defaults to <code>['/cgi-bin', '/htbin']</code> and describes
directories to treat as containing CGI scripts.
</dl>
<P>
The <tt class="class">CGIHTTPRequestHandler</tt> defines the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3613' xml:id='l2h-3613' class="method">do_POST</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This method serves the <code>'POST'</code> request type, only allowed for
CGI scripts. Error 501, "Can only POST to CGI scripts", is output
when trying to POST to a non-CGI url.
</dl>
<P>
Note that CGI scripts will be run with UID of user nobody, for security
reasons. Problems with the CGI script will be translated to error 403.
<P>
For example usage, see the implementation of the <tt class="function">test()</tt>
function.
<P>
<div class="seealso">
<p class="heading">See Also:</p>
<dl compact="compact" class="seemodule">
<dt>Module <b><tt class="module"><a href="module-BaseHTTPServer.html">BaseHTTPServer</a></tt>:</b>
<dd>Base class implementation for Web server
and request handler.
</dl>
</div>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.18 SimpleHTTPServer "
href="module-SimpleHTTPServer.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
href="internet.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.20 cookielib "
href="module-cookielib.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-SimpleHTTPServer.html">11.18 SimpleHTTPServer </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-cookielib.html">11.20 cookielib </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>