1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<link rel="stylesheet" href="style.css" type="text/css">
5
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
6
<link rel="Start" href="index.html">
7
<link rel="previous" href="Netcgi_types.cgi_argument.html">
8
<link rel="Up" href="Netcgi_types.html">
9
<link title="Index of types" rel=Appendix href="index_types.html">
10
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
11
<link title="Index of values" rel=Appendix href="index_values.html">
12
<link title="Index of class methods" rel=Appendix href="index_methods.html">
13
<link title="Index of classes" rel=Appendix href="index_classes.html">
14
<link title="Index of class types" rel=Appendix href="index_class_types.html">
15
<link title="Index of modules" rel=Appendix href="index_modules.html">
16
<link title="Netcgi_env" rel="Chapter" href="Netcgi_env.html">
17
<link title="Netcgi_types" rel="Chapter" href="Netcgi_types.html">
18
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
19
<link title="Netcgi_jserv" rel="Chapter" href="Netcgi_jserv.html">
20
<link title="Netcgi_jserv_ajp12" rel="Chapter" href="Netcgi_jserv_ajp12.html">
21
<link title="Netcgi_jserv_app" rel="Chapter" href="Netcgi_jserv_app.html">
22
<link title="Netcgi_fcgi_10" rel="Chapter" href="Netcgi_fcgi_10.html">
23
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
24
<link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html"><title>Ocamlnet 2 Reference Manual (netcgi1 add-on) : Netcgi_types.cgi_activation</title>
27
<div class="navbar"><a href="Netcgi_types.cgi_argument.html">Previous</a>
28
<a href="Netcgi_types.html">Up</a>
30
<center><h1>Class type <a href="type_Netcgi_types.cgi_activation.html">Netcgi_types.cgi_activation</a></h1></center>
32
<pre><span class="keyword">class type</span> <a name="TYPEcgi_activation"></a>cgi_activation = <code class="code">object</code> <a href="Netcgi_types.cgi_activation.html">..</a> <code class="code">end</code></pre>The common interface of CGI activation objects<br>
34
<pre><span class="keyword">method</span> <a name="METHODenvironment"></a>environment : <code class="type"><a href="Netcgi_env.cgi_environment.html">Netcgi_env.cgi_environment</a></code></pre><div class="info">
35
The CGI environment object. This object is the "outer layer" of the
36
activation object that connects it with real I/O channels.<br>
38
<pre><span class="keyword">method</span> <a name="METHODrequest_method"></a>request_method : <code class="type"><a href="Netcgi_types.html#TYPErequest_method">request_method</a></code></pre><div class="info">
41
<a name="2_Initialarguments"></a>
42
<h2>Initial arguments</h2>
45
Initial arguments are the CGI arguments at the time the arguments
46
were parsed from the environment.<pre><span class="keyword">method</span> <a name="METHODinitial_arguments"></a>initial_arguments : <code class="type">(string * <a href="Netcgi_types.cgi_argument.html">cgi_argument</a>) list</code></pre><div class="info">
47
The complete list of initial arguments<br>
49
<pre><span class="keyword">method</span> <a name="METHODinitial_argument"></a>initial_argument : <code class="type">string -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a></code></pre><div class="info">
50
Returns a certain initial argument, or raises <code class="code">Not_found</code><br>
52
<pre><span class="keyword">method</span> <a name="METHODinitial_argument_value"></a>initial_argument_value : <code class="type">?default:string -> string -> string</code></pre><div class="info">
53
Returns the value of the initial argument as string. If the
54
argument does not exist, the <code class="code">default</code> is returned. The
55
<code class="code">default</code> defaults to <code class="code">""</code>.<br>
57
<pre><span class="keyword">method</span> <a name="METHODinitial_multiple_argument"></a>initial_multiple_argument : <code class="type">string -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a> list</code></pre><div class="info">
58
Returns a certain initial argument that occurs several times in
59
the set of arguments<br>
61
<a name="2_Currentarguments"></a>
62
<h2>Current arguments</h2>
65
The current arguments can be modified, but they are initialized
66
to the initial arguments at object creation time:<pre><span class="keyword">method</span> <a name="METHODarguments"></a>arguments : <code class="type">(string * <a href="Netcgi_types.cgi_argument.html">cgi_argument</a>) list</code></pre><div class="info">
67
The complete list of current arguments<br>
69
<pre><span class="keyword">method</span> <a name="METHODargument"></a>argument : <code class="type">string -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a></code></pre><div class="info">
70
Returns a certain current argument, or raises <code class="code">Not_found</code><br>
72
<pre><span class="keyword">method</span> <a name="METHODargument_value"></a>argument_value : <code class="type">?default:string -> string -> string</code></pre><div class="info">
73
Returns the value of the current argument as string. If the
74
argument does not exist, the <code class="code">default</code> is returned. The
75
<code class="code">default</code> defaults to <code class="code">""</code>.<br>
77
<pre><span class="keyword">method</span> <a name="METHODmultiple_argument"></a>multiple_argument : <code class="type">string -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a> list</code></pre><div class="info">
78
Returns a certain current argument that occurs several times in
79
the set of arguments<br>
81
<a name="2_Modifythesetofcurrentarguments"></a>
82
<h2>Modify the set of current arguments</h2><pre><span class="keyword">method</span> <a name="METHODset_arguments"></a>set_arguments : <code class="type">?fin:bool -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a> list -> unit</code></pre><div class="info">
83
Replaces the set of current arguments with a new set.
86
<div class="param_info"><code class="code">fin</code> : If <code class="code">true</code>, the default, the arguments of the old set
87
that are not member of the new set are finalized</div>
88
<pre><span class="keyword">method</span> <a name="METHODupdate_argument"></a>update_argument : <code class="type">?fin:bool -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a> -> unit</code></pre><div class="info">
89
The passed argument replaces the current argument
90
(or multiple argument) with the same name; if there is no such
91
argument, the passed argument is added to the list of current args
94
<div class="param_info"><code class="code">fin</code> : If <code class="code">true</code>, the default, the replaced arguments are
95
finalized (unless they happen to be the same as the new argument)</div>
96
<pre><span class="keyword">method</span> <a name="METHODupdate_multiple_argument"></a>update_multiple_argument : <code class="type">?fin:bool -> <a href="Netcgi_types.cgi_argument.html">cgi_argument</a> list -> unit</code></pre><div class="info">
97
The passed arguments must all have the same name. They replace
98
the current argument (or multiple argument) with the same name;
99
if there is no such argument, the passed arguments are added to
100
the set of current arguments.
103
<div class="param_info"><code class="code">fin</code> : If <code class="code">true</code>, the default, the replaced arguments are
104
finalized (unless they happen to be the same as the new arguments)</div>
105
<pre><span class="keyword">method</span> <a name="METHODdelete_argument"></a>delete_argument : <code class="type">?fin:bool -> string -> unit</code></pre><div class="info">
106
Deletes all arguments with the passed name.
109
<div class="param_info"><code class="code">fin</code> : If <code class="code">true</code>, the default, the deleted arguments are
111
<a name="2_SelfreferencingURL"></a>
112
<h2>Self-referencing URL</h2><pre><span class="keyword">method</span> <a name="METHODurl"></a>url : <code class="type">?protocol:<a href="Netcgi_env.html#TYPEprotocol">Netcgi_env.protocol</a> -><br> ?with_authority:<a href="Netcgi_types.html#TYPEother_url_spec">other_url_spec</a> -><br> ?with_script_name:<a href="Netcgi_types.html#TYPEother_url_spec">other_url_spec</a> -><br> ?with_path_info:<a href="Netcgi_types.html#TYPEother_url_spec">other_url_spec</a> -><br> ?with_query_string:<a href="Netcgi_types.html#TYPEquery_string_spec">query_string_spec</a> -> unit -> string</code></pre><div class="info">
113
Returns the URL of the current CGI activation.
116
<li><code class="code">protocol</code>: The URL scheme. By default, the URL scheme is used
117
that is described in the environment</li>
118
<li><code class="code">with_authority</code>: Whether to include authority part of the URL, and
119
if yes, from which source. Default: <code class="code">`Env</code></li>
120
<li><code class="code">with_script_name</code>: Whether to include the part of the URL path
121
identifying the CGI script, and if yes, from which source.
122
Default: <code class="code">`Env</code></li>
123
<li><code class="code">with_path_info</code>: Whether to include the rest of the URL path
124
exceeding the script name, and if yes, from which source.
125
Default: <code class="code">`Env</code></li>
126
<li><code class="code">with_query_string</code>: Whether to include the query string,
127
and if yes, which one. Default: <code class="code">`None</code>, i.e. no query string</li>
131
<a name="2_GeneratingOutput"></a>
132
<h2>Generating Output</h2><pre><span class="keyword">method</span> <a name="METHODoutput"></a>output : <code class="type">Netchannels.trans_out_obj_channel</code></pre><div class="info">
133
The output channel to which the generated content is intended to
137
The output channel may have transactional semantics, and because of
138
this, it is an <code class="code">trans_out_obj_channel</code>. Implementations are free
139
to support transactions or not.
142
After all data have been written, the method <code class="code">commit_work</code> must be
143
called, even if there is no support for transactions.
149
<pre><code class="code"> cgi # output # output_string "Hello world!\n";
150
cgi # output # commit_work()
154
Example for an error handler and a transaction buffer:
155
If an error happens, it is possible to roll the channel back, and
156
to write the error message.
157
<pre><code class="code"> try
158
cgi # set_header ... ();
159
cgi # output # output_string "Hello World!"; ...
160
cgi # output # commit_work();
163
cgi # output # rollback_work();
164
cgi # set_header ... ();
165
cgi # output # output_string "Software error!"; ...
166
cgi # output # commit_work();
169
<pre><span class="keyword">method</span> <a name="METHODset_header"></a>set_header : <code class="type">?status:<a href="Netcgi_types.html#TYPEstatus">status</a> -><br> ?content_type:string -><br> ?cache:<a href="Netcgi_types.html#TYPEcache_control">cache_control</a> -><br> ?filename:string -><br> ?language:string -><br> ?script_type:string -><br> ?style_type:string -><br> ?set_cookie:<a href="Netcgi_types.html#TYPEcgi_cookie">cgi_cookie</a> list -><br> ?fields:(string * string list) list -> unit -> unit</code></pre><div class="info">
173
When the output channel supports transactions, it is possible to
174
set the header until the channel is commited for the first time.
175
When there is no support for transactions, the header must be
176
set before the first byte of output is written.
179
If <code class="code">set_header</code> is called several times, <i>all</i> of the header fields
183
<li><code class="code">status</code>: Sets the HTTP status of the reply. Defaults to "no status",
184
but the server normally complements an <code class="code">`Ok</code> status in this case</li>
185
<li><code class="code">content_type</code>: Sets the content type. Defaults to "text/html" if the
186
content type is not yet set.</li>
187
<li><code class="code">cache</code>: Sets the cache behavior for replies to GET requests. The
188
default is <code class="code">`Unspecified</code>. <b>It is strongly recommended to specify
189
the caching behaviour!!!</b> You are on the safe side with <code class="code">`No_cache</code>,
190
forcing every page to be regenerated. If your data do not change
191
frequently, <code class="code">`Max_age n</code> tells the caches to store the data at most
192
<code class="code">n</code> seconds.</li>
193
<li><code class="code">filename</code>: Sets the filename associated with the page. This filename
194
is taken for the "save as..." dialog. Default: no filename.
195
Note: It is bad practice if the filename contains problematic characters
196
(backslash, double quote, space), or the names of directories</li>
197
<li><code class="code">script_type</code>: Sets the language of the script tag (for HTML replies).
198
It is recommended to use this field if there are <code class="code">ONXXX</code> attributes
199
containing scripts before the first <code class="code"><SCRIPT></code> element, because you
200
cannot specify the script language for the <code class="code">ONXXX</code> attributes otherwise.
201
<code class="code">script_type</code> must be a media type, e.g. "text/javascript".
202
Default: no language is specified.</li>
203
<li><code class="code">style_type</code>: Sets the language of the style tag (for HTML replies).
204
It is recommended to use this field if there are <code class="code">STYLE</code> attributes
205
containing scripts before the first <code class="code"><STYLE></code> element, because you
206
cannot specify the style language for the <code class="code">STYLE</code> attributes otherwise.
207
<code class="code">style_type</code> must be a media type, e.g. "text/css".
208
Default: no language is specified.</li>
209
<li><code class="code">set_cookie</code>: Sets a number of cookies.
210
Default: <code class="code">[]</code>
211
You can query the cookies using <code class="code">environment#cookies</code>.</li>
212
<li><code class="code">fields</code>: Sets other fields of the header.</li>
216
<pre><span class="keyword">method</span> <a name="METHODset_redirection_header"></a>set_redirection_header : <code class="type">string -> unit</code></pre><div class="info">
217
Sets the header such that a redirection to the specified URL
218
is performed. If the URL begins with "http:" the redirection directive is
219
passed back to the client, and the client will repeat the request for
220
the new location. If the URL begins with "/", the server performs the
221
redirection, and it is invisible for the client.<br>
223
<a name="2_CleaningUp"></a>
224
<h2>Cleaning Up</h2><pre><span class="keyword">method</span> <a name="METHODfinalize"></a>finalize : <code class="type">unit -> unit</code></pre><div class="info">
225
This method calls <code class="code">finalize</code> for every CGI argument to ensure that
226
all files are deleted.
227
It does not close the in/out channels, however.
228
This method is not registered in the garbage collector, and it is
229
a bad idea to do so.<br>
b'\\ No newline at end of file'