-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBase--WebServer--Process.html
More file actions
291 lines (237 loc) · 12.8 KB
/
Copy pathBase--WebServer--Process.html
File metadata and controls
291 lines (237 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Base::WebServer::Process - Object for obtaining web server request info and sending response messages : OpenKore source code documentation</title>
<link rel="stylesheet" type="text/css" href="openkore.css">
<link rel="stylesheet" type="text/css" href="highlight.css">
<!-- Fix broken PNG transparency for IE/Win5-6+ -->
<!--[if gte IE 5.5000]>
<script type="text/javascript" src="pngfix.js"></script>
<![endif]-->
</head>
<body>
<div id="title">OpenKore source code documentation</div>
<div id="navigation">
<ul>
<li><a href="http://www.openkore.com/">Main website</a></li>
<li><a href="index.html">Table of contents</a></li>
<li><b>Base::WebServer::Process</b></li>
</ul>
</div>
<div id="main">
<h1>Base::WebServer::Process - Object for obtaining web server request info and sending response messages</h1>
This is the object you use for obtaining information about a request, and to reply to a request.
It has a PHP-like interface.
<p>
You should also read <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">the HTTP specification</a>.
<p><table class="functionIndex">
<tr><th colspan="3">Functions in this module</th></tr><tr onclick="location.href='#$BaseWebServerProcess->GET';">
<td class="return-type">Hash<Bytes>*</td>
<td class="func"><a href="#$BaseWebServerProcess->GET">$BaseWebServerProcess->GET</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->clientHeader';">
<td class="return-type">String</td>
<td class="func"><a href="#$BaseWebServerProcess->clientHeader">$BaseWebServerProcess->clientHeader</a></td>
<td class="decl">(<span class="type">String</span> name)</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->file';">
<td class="return-type">String</td>
<td class="func"><a href="#$BaseWebServerProcess->file">$BaseWebServerProcess->file</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->header';">
<td class="return-type">void</td>
<td class="func"><a href="#$BaseWebServerProcess->header">$BaseWebServerProcess->header</a></td>
<td class="decl">(<span class="type">String</span> name, String value)</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->print';">
<td class="return-type">void</td>
<td class="func"><a href="#$BaseWebServerProcess->print">$BaseWebServerProcess->print</a></td>
<td class="decl">(<span class="type">String</span> content)</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->shortResponse';">
<td class="return-type">void</td>
<td class="func"><a href="#$BaseWebServerProcess->shortResponse">$BaseWebServerProcess->shortResponse</a></td>
<td class="decl">(<span class="type">String</span> content)</td>
</tr><tr onclick="location.href='#$BaseWebServerProcess->status';">
<td class="return-type">void</td>
<td class="func"><a href="#$BaseWebServerProcess->status">$BaseWebServerProcess->status</a></td>
<td class="decl">(<span class="type">int</span> statusCode, String statusMsg)</td>
</tr>
</table>
<p><hr class="details_sep">
<h2>Details</h2>
<div class="details">
<p>
<div class="function"><a name="$BaseWebServerProcess->GET"></a>
<h3>$BaseWebServerProcess->GET</h3>
<dl>
<dt class="decl">
<span class="return-type"> Hash<Bytes>*</span> <strong>$BaseWebServerProcess->GET</strong>()
</dt>
<dd>
<dl class="params_and_returns">
<dt class="returns"><strong>Returns:</strong></dt>
<dd class="returns">a reference to a hash.</dd>
</dl><p>
<div class="desc">Returns a reference to a hash, which contains variables provided via
the URL query string.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->clientHeader"></a>
<h3>$BaseWebServerProcess->clientHeader</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$BaseWebServerProcess->clientHeader</strong>(<span class="type">String</span> name)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>name</code> : the name of the header you want to lookup.</dd>
<dt class="returns"><strong>Returns:</strong></dt>
<dd class="returns">the value of the header, or undef if the browser didn't send that header.</dd>
</dl><p>
<div class="desc">Lookup the value of a header the browser sent you.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->file"></a>
<h3>$BaseWebServerProcess->file</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$BaseWebServerProcess->file</strong>()
</dt>
<dd>
<dl class="params_and_returns">
<dt class="ensures"><strong>Ensures:</strong></dt>
<dd class="ensures">defined(result)</dd>
</dl><p>
<div class="desc">Returns the name of the file that the web browser requested.
The return value does not include the host name and does not include everythign after '?', so it will be something like "/foo/bar.html".</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->header"></a>
<h3>$BaseWebServerProcess->header</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$BaseWebServerProcess->header</strong>(<span class="type">String</span> name, String value)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>name</code> : the name of the header.</dd>
<dd class="param"><code>value</code> : the value of the header.</dd>
<dt class="requires"><strong>Requires:</strong></dt>
<dd class="requires"> defined(name) <br> defined(value) <br> $BaseWebServerProcess->print() or $BaseWebServerProcess->shortResponse() must not have been called before.</dd>
</dl><p>
<div class="desc">Schedule a HTTP header for sending. This header will be sent when the connection to the web browser is closed,
or when you first call <a href="Base--WebServer--Process.html#$BaseWebServerProcess->print"><code>$BaseWebServerProcess->print()</code></a> or <a href="Base--WebServer--Process.html#$BaseWebServerProcess->shortResponse"><code>$BaseWebServerProcess->shortResponse()</code></a>. If you have sent a header with
the same name before, the previous header is overwritten by this one.
<p>
For sending HTTP status messages, you should use <a href="Base--WebServer--Process.html#$BaseWebServerProcess->status"><code>$BaseWebServerProcess->status()</code></a> instead.</div>
<dl class="example">
<dt><strong>Example:</strong></dt>
<dd><pre><span class="hl kwb">$BaseWebServerProcess</span><span class="hl sym">-></span><span class="hl kwd">header</span><span class="hl sym">(</span><span class="hl str">"WWW-Authenticate"</span><span class="hl sym">,</span> <span class="hl str">"Negotiate"</span><span class="hl sym">);</span>
<span class="hl kwb">$BaseWebServerProcess</span><span class="hl sym">-></span><span class="hl kwd">header</span><span class="hl sym">(</span><span class="hl str">"WWW-Authenticate"</span><span class="hl sym">,</span> <span class="hl str">"NTLM"</span><span class="hl sym">);</span>
</pre></dd>
</dl>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->print"></a>
<h3>$BaseWebServerProcess->print</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$BaseWebServerProcess->print</strong>(<span class="type">String</span> content)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>content</code> : the content to print.</dd>
<dt class="requires"><strong>Requires:</strong></dt>
<dd class="requires">defined($content)</dd>
</dl><p>
<div class="desc">Output a string to the web browser. Any scheduled headers and status message will be sent first.
So after calling this function, you cannot send headers or a status message anymore.
<p>
The default status message is "200 OK". The default Content-Type is "text/html; charset=utf-8".
<p>
Should should send the Content-Length header (see HTTP specification) before calling this function,
if possible. That header allows the web browser to keep persistent connections to the server,
and to display download progress.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->shortResponse"></a>
<h3>$BaseWebServerProcess->shortResponse</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$BaseWebServerProcess->shortResponse</strong>(<span class="type">String</span> content)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>content</code> : the data to send to the web browser.</dd>
<dt class="requires"><strong>Requires:</strong></dt>
<dd class="requires">defined($content)</dd>
</dl><p>
<div class="desc">Send data (usually HTML) to the web server. This function also automatically sets the HTTP Content-Length
header for you, allowing the browser to keep the HTTP connection persistent, and to display download
progress information.
<p>
<b>Warning:</b> after calling this function, you shouldn't call any of the other functions in this class
which send data to the web server. It is undefined what will happen if you do so.
<p>
This function should only be used for small amount of data, because the entire content has to be in memory.
For larger amounts of data, you should send small chunks of data incrementally using <a href="Base--WebServer--Process.html#$BaseWebServerProcess->print"><code>$BaseWebServerProcess->print()</code></a>.
<p>
The default status message is "200 OK". The default Content-Type is "text/html; charset=utf-8".</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$BaseWebServerProcess->status"></a>
<h3>$BaseWebServerProcess->status</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$BaseWebServerProcess->status</strong>(<span class="type">int</span> statusCode, String statusMsg)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>statusCode</code> : a HTTP status code.</dd>
<dd class="param"><code>statusMsg</code> : the associated HTTP status message.</dd>
<dt class="requires"><strong>Requires:</strong></dt>
<dd class="requires"> defined($statusMsg) <br> $BaseWebServerProcess->print() or $BaseWebServerProcess->shortResponse() must not have been called before.</dd>
</dl><p>
<div class="desc">Schedule a HTTP response status message for sending. See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">the
HTTP specification</a> (section 10) for a list of codes. This status code will be sent when the connection to
the web browser is closed, or when you first call <a href="Base--WebServer--Process.html#$BaseWebServerProcess->print"><code>$BaseWebServerProcess->print()</code></a> or <a href="Base--WebServer--Process.html#$BaseWebServerProcess->shortResponse"><code>$BaseWebServerProcess->shortResponse()</code></a>.
If you have sent a HTTP status before, the previous status is overwritten by this one.
<p>
See also: <a href="Base--WebServer--Process.html#$BaseWebServerProcess->header"><code>$BaseWebServerProcess->header()</code></a></div>
<dl class="example">
<dt><strong>Example:</strong></dt>
<dd><pre><span class="hl kwb">$BaseWebServerProcess</span><span class="hl sym">-></span><span class="hl kwd">status</span><span class="hl sym">(</span><span class="hl num">404</span><span class="hl sym">,</span> <span class="hl str">"File Not Found"</span><span class="hl sym">);</span>
</pre></dd>
</dl>
</dd>
</dl>
</div>
</div>
<p><hr><p>
<div id="footer">
<ul>
<li><a href="http://validator.w3.org/check?uri=referer" title="Valid HTML 4.01!"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a></li>
<li><a href="http://www.mozilla.com/" title="Get Firefox - Take Back the Web"><img width="104" height="32" src="http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png" alt="Get Firefox - Take Back the Web"></a></li>
<li><a href="http://www.mozilla.com/" title="If you were looking at this page in any browser but Microsoft Internet Explorer, it would look and run better and faster"><img width="45" height="45" src="http://linuxart.com/img/noIE-small.png" alt="If you were looking at this page in any browser but Microsoft Internet Explorer, it would look and run better and faster"></a></li>
</ul>
Last modified: Fri Nov 16 10:05:11 2012
</div>
</div>
</body>
</html>