Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / module-CGIHTTPServer.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-cookielib.html" />
13<link rel="prev" href="module-SimpleHTTPServer.html" />
14<link rel="parent" href="internet.html" />
15<link rel="next" href="module-cookielib.html" />
16<meta name='aesop' content='information' />
17<title>11.19 CGIHTTPServer -- CGI-capable HTTP request handler</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.18 SimpleHTTPServer "
25 href="module-SimpleHTTPServer.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
28 href="internet.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.20 cookielib "
31 href="module-cookielib.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-SimpleHTTPServer.html">11.18 SimpleHTTPServer </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-cookielib.html">11.20 cookielib </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION00131900000000000000000">
5611.19 <tt class="module">CGIHTTPServer</tt> --
57 CGI-capable HTTP request handler</A>
58</H1>
59
60<P>
61<A NAME="module-CGIHTTPServer"></A>
62
63<P>
64The <tt class="module">CGIHTTPServer</tt> module defines a request-handler class,
65interface compatible with
66<tt class="class">BaseHTTPServer.BaseHTTPRequestHandler</tt> and inherits behavior
67from <tt class="class">SimpleHTTPServer.SimpleHTTPRequestHandler</tt> but can also
68run CGI scripts.
69
70<P>
71<span class="note"><b class="label">Note:</b>
72This module can run CGI scripts on <span class="Unix">Unix</span> and Windows systems;
73on Mac OS it will only be able to run Python scripts within the same
74process as itself.</span>
75
76<P>
77The <tt class="module">CGIHTTPServer</tt> module defines the following class:
78
79<P>
80<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
81 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-3611' xml:id='l2h-3611' class="class">CGIHTTPRequestHandler</tt></b>(</nobr></td>
82 <td><var>request, client_address, server</var>)</td></tr></table></dt>
83<dd>
84This class is used to serve either files or output of CGI scripts from
85the current directory and below. Note that mapping HTTP hierarchic
86structure to local directory structure is exactly as in
87<tt class="class">SimpleHTTPServer.SimpleHTTPRequestHandler</tt>.
88
89<P>
90The class will however, run the CGI script, instead of serving it as a
91file, if it guesses it to be a CGI script. Only directory-based CGI
92are used -- the other common server configuration is to treat special
93extensions as denoting CGI scripts.
94
95<P>
96The <tt class="function">do_GET()</tt> and <tt class="function">do_HEAD()</tt> functions are
97modified to run CGI scripts and serve the output, instead of serving
98files, if the request leads to somewhere below the
99<code>cgi_directories</code> path.
100</dl>
101
102<P>
103The <tt class="class">CGIHTTPRequestHandler</tt> defines the following data member:
104
105<P>
106<dl><dt><b><tt id='l2h-3612' xml:id='l2h-3612' class="member">cgi_directories</tt></b></dt>
107<dd>
108This defaults to <code>['/cgi-bin', '/htbin']</code> and describes
109directories to treat as containing CGI scripts.
110</dl>
111
112<P>
113The <tt class="class">CGIHTTPRequestHandler</tt> defines the following methods:
114
115<P>
116<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
117 <td><nobr><b><tt id='l2h-3613' xml:id='l2h-3613' class="method">do_POST</tt></b>(</nobr></td>
118 <td><var></var>)</td></tr></table></dt>
119<dd>
120This method serves the <code>'POST'</code> request type, only allowed for
121CGI scripts. Error 501, "Can only POST to CGI scripts", is output
122when trying to POST to a non-CGI url.
123</dl>
124
125<P>
126Note that CGI scripts will be run with UID of user nobody, for security
127reasons. Problems with the CGI script will be translated to error 403.
128
129<P>
130For example usage, see the implementation of the <tt class="function">test()</tt>
131function.
132
133<P>
134<div class="seealso">
135 <p class="heading">See Also:</p>
136
137 <dl compact="compact" class="seemodule">
138 <dt>Module <b><tt class="module"><a href="module-BaseHTTPServer.html">BaseHTTPServer</a></tt>:</b>
139 <dd>Base class implementation for Web server
140 and request handler.
141 </dl>
142</div>
143
144<DIV CLASS="navigation">
145<div class='online-navigation'>
146<p></p><hr />
147<table align="center" width="100%" cellpadding="0" cellspacing="2">
148<tr>
149<td class='online-navigation'><a rel="prev" title="11.18 SimpleHTTPServer "
150 href="module-SimpleHTTPServer.html"><img src='../icons/previous.png'
151 border='0' height='32' alt='Previous Page' width='32' /></A></td>
152<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
153 href="internet.html"><img src='../icons/up.png'
154 border='0' height='32' alt='Up One Level' width='32' /></A></td>
155<td class='online-navigation'><a rel="next" title="11.20 cookielib "
156 href="module-cookielib.html"><img src='../icons/next.png'
157 border='0' height='32' alt='Next Page' width='32' /></A></td>
158<td align="center" width="100%">Python Library Reference</td>
159<td class='online-navigation'><a rel="contents" title="Table of Contents"
160 href="contents.html"><img src='../icons/contents.png'
161 border='0' height='32' alt='Contents' width='32' /></A></td>
162<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
163 border='0' height='32' alt='Module Index' width='32' /></a></td>
164<td class='online-navigation'><a rel="index" title="Index"
165 href="genindex.html"><img src='../icons/index.png'
166 border='0' height='32' alt='Index' width='32' /></A></td>
167</tr></table>
168<div class='online-navigation'>
169<b class="navlabel">Previous:</b>
170<a class="sectref" rel="prev" href="module-SimpleHTTPServer.html">11.18 SimpleHTTPServer </A>
171<b class="navlabel">Up:</b>
172<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
173<b class="navlabel">Next:</b>
174<a class="sectref" rel="next" href="module-cookielib.html">11.20 cookielib </A>
175</div>
176</div>
177<hr />
178<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
179</DIV>
180<!--End of Navigation Panel-->
181<ADDRESS>
182See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
183</ADDRESS>
184</BODY>
185</HTML>