You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
11 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>cgi - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package cgi</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "net/http/cgi"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package cgi implements CGI (Common Gateway Interface) as specified
  68. in RFC 3875.
  69. </p>
  70. <p>
  71. Note that using CGI means starting a new process to handle each
  72. request, which is typically less efficient than using a
  73. long-running server. This package is intended primarily for
  74. compatibility with existing systems.
  75. </p>
  76. </div>
  77. </div>
  78. <div id="pkg-index" class="toggleVisible">
  79. <div class="collapsed">
  80. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  81. </div>
  82. <div class="expanded">
  83. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  84. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  85. <div id="manual-nav">
  86. <dl>
  87. <dd><a href="index.html#Request">func Request() (*http.Request, error)</a></dd>
  88. <dd><a href="index.html#RequestFromMap">func RequestFromMap(params map[string]string) (*http.Request, error)</a></dd>
  89. <dd><a href="index.html#Serve">func Serve(handler http.Handler) error</a></dd>
  90. <dd><a href="index.html#Handler">type Handler</a></dd>
  91. <dd>&nbsp; &nbsp; <a href="index.html#Handler.ServeHTTP">func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)</a></dd>
  92. </dl>
  93. </div><!-- #manual-nav -->
  94. <h4>Package files</h4>
  95. <p>
  96. <span style="font-size:90%">
  97. <a href="http://localhost:6060/src/net/http/cgi/child.go">child.go</a>
  98. <a href="http://localhost:6060/src/net/http/cgi/host.go">host.go</a>
  99. </span>
  100. </p>
  101. </div><!-- .expanded -->
  102. </div><!-- #pkg-index -->
  103. <div id="pkg-callgraph" class="toggle" style="display: none">
  104. <div class="collapsed">
  105. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  106. </div> <!-- .expanded -->
  107. <div class="expanded">
  108. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  109. <p>
  110. In the call graph viewer below, each node
  111. is a function belonging to this package
  112. and its children are the functions it
  113. calls&mdash;perhaps dynamically.
  114. </p>
  115. <p>
  116. The root nodes are the entry points of the
  117. package: functions that may be called from
  118. outside the package.
  119. There may be non-exported or anonymous
  120. functions among them if they are called
  121. dynamically from another package.
  122. </p>
  123. <p>
  124. Click a node to visit that function's source code.
  125. From there you can visit its callers by
  126. clicking its declaring <code>func</code>
  127. token.
  128. </p>
  129. <p>
  130. Functions may be omitted if they were
  131. determined to be unreachable in the
  132. particular programs or tests that were
  133. analyzed.
  134. </p>
  135. <!-- Zero means show all package entry points. -->
  136. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  137. </div>
  138. </div> <!-- #pkg-callgraph -->
  139. <h2 id="Request">func <a href="http://localhost:6060/src/net/http/cgi/child.go?s=604:641#L19">Request</a></h2>
  140. <pre>func Request() (*<a href="../index.html">http</a>.<a href="../index.html#Request">Request</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  141. <p>
  142. Request returns the HTTP request as represented in the current
  143. environment. This assumes the current program is being run
  144. by a web server in a CGI environment.
  145. The returned Request&#39;s Body is populated, if applicable.
  146. </p>
  147. <h2 id="RequestFromMap">func <a href="http://localhost:6060/src/net/http/cgi/child.go?s=1163:1231#L42">RequestFromMap</a></h2>
  148. <pre>func RequestFromMap(params map[<a href="../../../builtin/index.html#string">string</a>]<a href="../../../builtin/index.html#string">string</a>) (*<a href="../index.html">http</a>.<a href="../index.html#Request">Request</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  149. <p>
  150. RequestFromMap creates an http.Request from CGI variables.
  151. The returned Request&#39;s Body field is not populated.
  152. </p>
  153. <h2 id="Serve">func <a href="http://localhost:6060/src/net/http/cgi/child.go?s=3875:3913#L136">Serve</a></h2>
  154. <pre>func Serve(handler <a href="../index.html">http</a>.<a href="../index.html#Handler">Handler</a>) <a href="../../../builtin/index.html#error">error</a></pre>
  155. <p>
  156. Serve executes the provided Handler on the currently active CGI
  157. request, if any. If there&#39;s no current CGI environment
  158. an error is returned. The provided handler may be nil to use
  159. http.DefaultServeMux.
  160. </p>
  161. <h2 id="Handler">type <a href="http://localhost:6060/src/net/http/cgi/host.go?s=1283:2347#L37">Handler</a></h2>
  162. <pre>type Handler struct {
  163. Path <a href="../../../builtin/index.html#string">string</a> <span class="comment">// path to the CGI executable</span>
  164. Root <a href="../../../builtin/index.html#string">string</a> <span class="comment">// root URI prefix of handler or empty for &#34;/&#34;</span>
  165. <span class="comment">// Dir specifies the CGI executable&#39;s working directory.</span>
  166. <span class="comment">// If Dir is empty, the base directory of Path is used.</span>
  167. <span class="comment">// If Path has no base directory, the current working</span>
  168. <span class="comment">// directory is used.</span>
  169. Dir <a href="../../../builtin/index.html#string">string</a>
  170. Env []<a href="../../../builtin/index.html#string">string</a> <span class="comment">// extra environment variables to set, if any, as &#34;key=value&#34;</span>
  171. InheritEnv []<a href="../../../builtin/index.html#string">string</a> <span class="comment">// environment variables to inherit from host, as &#34;key&#34;</span>
  172. Logger *<a href="../../../log/index.html">log</a>.<a href="../../../log/index.html#Logger">Logger</a> <span class="comment">// optional log for errors or nil to use log.Print</span>
  173. Args []<a href="../../../builtin/index.html#string">string</a> <span class="comment">// optional arguments to pass to child process</span>
  174. <span class="comment">// PathLocationHandler specifies the root http Handler that</span>
  175. <span class="comment">// should handle internal redirects when the CGI process</span>
  176. <span class="comment">// returns a Location header value starting with a &#34;/&#34;, as</span>
  177. <span class="comment">// specified in RFC 3875 § 6.3.2. This will likely be</span>
  178. <span class="comment">// http.DefaultServeMux.</span>
  179. <span class="comment">//</span>
  180. <span class="comment">// If nil, a CGI response with a local URI path is instead sent</span>
  181. <span class="comment">// back to the client and not redirected internally.</span>
  182. PathLocationHandler <a href="../index.html">http</a>.<a href="../index.html#Handler">Handler</a>
  183. }</pre>
  184. <p>
  185. Handler runs an executable in a subprocess with a CGI environment.
  186. </p>
  187. <h3 id="Handler.ServeHTTP">func (*Handler) <a href="http://localhost:6060/src/net/http/cgi/host.go?s=2914:2984#L88">ServeHTTP</a></h3>
  188. <pre>func (h *<a href="index.html#Handler">Handler</a>) ServeHTTP(rw <a href="../index.html">http</a>.<a href="../index.html#ResponseWriter">ResponseWriter</a>, req *<a href="../index.html">http</a>.<a href="../index.html#Request">Request</a>)</pre>
  189. <div id="footer">
  190. Build version go1.6.<br>
  191. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  192. the content of this page is licensed under the
  193. Creative Commons Attribution 3.0 License,
  194. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  195. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  196. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  197. </div>
  198. </div><!-- .container -->
  199. </div><!-- #page -->
  200. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  201. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  202. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  203. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  204. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  205. </body>
  206. </html>