mongrel 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +10 -2
- data/Rakefile +1 -1
- data/doc/rdoc/classes/Mongrel.html +11 -1
- data/doc/rdoc/classes/Mongrel/Const.html +342 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.html +201 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000008.html +20 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000009.html +31 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000010.html +22 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000011.html +39 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000023.html → M000028.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000024.html → M000029.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +28 -10
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000013.html → M000017.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000018.html +21 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +5 -18
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000019.html → M000023.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +8 -8
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000030.html +31 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +89 -15
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000020.html → M000024.html} +7 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000021.html → M000025.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000026.html +19 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000022.html → M000027.html} +11 -11
- data/doc/rdoc/classes/Mongrel/HttpServer.html +32 -76
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +18 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html +64 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000010.html → M000014.html} +9 -8
- data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000011.html → M000015.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000016.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +25 -23
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000015.html → M000019.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000016.html → M000020.html} +3 -2
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000017.html → M000021.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000018.html → M000022.html} +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +14 -2
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +23 -18
- data/examples/simpletest.rb +2 -1
- data/ext/http11/http11.c +10 -9
- data/ext/http11/http11_parser.c +10 -10
- data/ext/http11/http11_parser.h +5 -1
- data/lib/#mongrel.rb# +493 -0
- data/lib/mongrel.rb +242 -48
- metadata +28 -19
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000025.html +0 -30
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +0 -26
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html +0 -58
@@ -10,12 +10,12 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 218</span>
|
14
|
+
218: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">socket</span>)
|
15
|
+
219: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span>
|
16
|
+
220: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
|
17
|
+
221: <span class="ruby-ivar">@status</span> = <span class="ruby-value">404</span>
|
18
|
+
222: <span class="ruby-ivar">@header</span> = <span class="ruby-constant">HeaderOut</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>)
|
19
|
+
223: <span class="ruby-keyword kw">end</span></pre>
|
20
20
|
</body>
|
21
21
|
</html>
|
@@ -10,11 +10,11 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 229</span>
|
14
|
+
229: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>(<span class="ruby-identifier">status</span>=<span class="ruby-value">200</span>)
|
15
|
+
230: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
|
16
|
+
231: <span class="ruby-keyword kw">yield</span> <span class="ruby-ivar">@header</span>, <span class="ruby-ivar">@body</span>
|
17
|
+
232: <span class="ruby-identifier">finished</span>
|
18
|
+
233: <span class="ruby-keyword kw">end</span></pre>
|
19
19
|
</body>
|
20
20
|
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>reset (Mongrel::HttpResponse)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 237</span>
|
14
|
+
237: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
|
15
|
+
238: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
|
16
|
+
239: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
|
17
|
+
240: <span class="ruby-keyword kw">end</span></pre>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -10,16 +10,16 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 244</span>
|
14
|
+
244: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finished</span>
|
15
|
+
245: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
|
16
|
+
246: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
|
17
|
+
247:
|
18
|
+
248: <span class="ruby-comment cmt"># connection: close is also added to ensure that the client does not pipeline.</span>
|
19
|
+
249: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">"HTTP/1.1 #{@status} #{HTTP_STATUS_CODES[@status]}\r\nContent-Length: #{@body.length}\r\nConnection: close\r\n"</span>)
|
20
|
+
250: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span>)
|
21
|
+
251: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">"\r\n"</span>)
|
22
|
+
252: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@body</span>.<span class="ruby-identifier">read</span>)
|
23
|
+
253: <span class="ruby-keyword kw">end</span></pre>
|
24
24
|
</body>
|
25
25
|
</html>
|
@@ -85,7 +85,7 @@ Mognrel::HttpParser and <a
|
|
85
85
|
href="URIClassifier.html">Mongrel::URIClassifier</a> make up the majority
|
86
86
|
of how the server functions. It’s a very simple class that just has a
|
87
87
|
thread accepting connections and a simple <a
|
88
|
-
href="HttpServer.html#
|
88
|
+
href="HttpServer.html#M000013">HttpServer.process_client</a> function to do
|
89
89
|
the heavy lifting with the IO and Ruby.
|
90
90
|
</p>
|
91
91
|
<p>
|
@@ -119,11 +119,11 @@ finally useful.
|
|
119
119
|
<h3 class="section-bar">Methods</h3>
|
120
120
|
|
121
121
|
<div class="name-list">
|
122
|
-
<a href="#
|
123
|
-
<a href="#
|
124
|
-
<a href="#
|
125
|
-
<a href="#
|
126
|
-
<a href="#
|
122
|
+
<a href="#M000012">new</a>
|
123
|
+
<a href="#M000013">process_client</a>
|
124
|
+
<a href="#M000015">register</a>
|
125
|
+
<a href="#M000014">run</a>
|
126
|
+
<a href="#M000016">unregister</a>
|
127
127
|
</div>
|
128
128
|
</div>
|
129
129
|
|
@@ -135,50 +135,6 @@ finally useful.
|
|
135
135
|
<div id="section">
|
136
136
|
|
137
137
|
|
138
|
-
<div id="constants-list">
|
139
|
-
<h3 class="section-bar">Constants</h3>
|
140
|
-
|
141
|
-
<div class="name-list">
|
142
|
-
<table summary="Constants">
|
143
|
-
<tr class="top-aligned-row context-row">
|
144
|
-
<td class="context-item-name">ERROR_404_RESPONSE</td>
|
145
|
-
<td>=</td>
|
146
|
-
<td class="context-item-value">"HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: Mongrel/0.2\r\n\r\nNOT FOUND"</td>
|
147
|
-
<td width="3em"> </td>
|
148
|
-
<td class="context-item-desc">
|
149
|
-
The standard empty 404 response for bad requests. Use Error4040Handler for
|
150
|
-
custom stuff.
|
151
|
-
|
152
|
-
</td>
|
153
|
-
</tr>
|
154
|
-
<tr class="top-aligned-row context-row">
|
155
|
-
<td class="context-item-name">ERROR_503_RESPONSE</td>
|
156
|
-
<td>=</td>
|
157
|
-
<td class="context-item-value">"HTTP/1.1 503 Service Unavailable\r\n\r\nBUSY"</td>
|
158
|
-
</tr>
|
159
|
-
<tr class="top-aligned-row context-row">
|
160
|
-
<td class="context-item-name">CHUNK_SIZE</td>
|
161
|
-
<td>=</td>
|
162
|
-
<td class="context-item-value">(16 * 1024)</td>
|
163
|
-
<td width="3em"> </td>
|
164
|
-
<td class="context-item-desc">
|
165
|
-
The basic max request size we’ll try to read.
|
166
|
-
|
167
|
-
</td>
|
168
|
-
</tr>
|
169
|
-
<tr class="top-aligned-row context-row">
|
170
|
-
<td class="context-item-name">PATH_INFO</td>
|
171
|
-
<td>=</td>
|
172
|
-
<td class="context-item-value">"PATH_INFO"</td>
|
173
|
-
</tr>
|
174
|
-
<tr class="top-aligned-row context-row">
|
175
|
-
<td class="context-item-name">SCRIPT_NAME</td>
|
176
|
-
<td>=</td>
|
177
|
-
<td class="context-item-value">"SCRIPT_NAME"</td>
|
178
|
-
</tr>
|
179
|
-
</table>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
138
|
|
183
139
|
|
184
140
|
|
@@ -202,12 +158,12 @@ The basic max request size we’ll try to read.
|
|
202
158
|
<div id="methods">
|
203
159
|
<h3 class="section-bar">Public Class methods</h3>
|
204
160
|
|
205
|
-
<div id="method-
|
206
|
-
<a name="
|
161
|
+
<div id="method-M000012" class="method-detail">
|
162
|
+
<a name="M000012"></a>
|
207
163
|
|
208
164
|
<div class="method-heading">
|
209
|
-
<a href="HttpServer.src/
|
210
|
-
onclick="popupCode('HttpServer.src/
|
165
|
+
<a href="HttpServer.src/M000012.html" target="Code" class="method-signature"
|
166
|
+
onclick="popupCode('HttpServer.src/M000012.html');return false;">
|
211
167
|
<span class="method-name">new</span><span class="method-args">(host, port, num_processors=20)</span>
|
212
168
|
</a>
|
213
169
|
</div>
|
@@ -239,12 +195,12 @@ href="../Mongrel.html">Mongrel</a> will make this more dynamic (hopefully).
|
|
239
195
|
|
240
196
|
<h3 class="section-bar">Public Instance methods</h3>
|
241
197
|
|
242
|
-
<div id="method-
|
243
|
-
<a name="
|
198
|
+
<div id="method-M000013" class="method-detail">
|
199
|
+
<a name="M000013"></a>
|
244
200
|
|
245
201
|
<div class="method-heading">
|
246
|
-
<a href="HttpServer.src/
|
247
|
-
onclick="popupCode('HttpServer.src/
|
202
|
+
<a href="HttpServer.src/M000013.html" target="Code" class="method-signature"
|
203
|
+
onclick="popupCode('HttpServer.src/M000013.html');return false;">
|
248
204
|
<span class="method-name">process_client</span><span class="method-args">(client)</span>
|
249
205
|
</a>
|
250
206
|
</div>
|
@@ -253,20 +209,20 @@ href="../Mongrel.html">Mongrel</a> will make this more dynamic (hopefully).
|
|
253
209
|
<p>
|
254
210
|
Does the majority of the IO processing. It has been written in Ruby using
|
255
211
|
about 7 different IO processing strategies and no matter how it’s
|
256
|
-
done the performance just does not improve.
|
257
|
-
|
258
|
-
|
259
|
-
|
212
|
+
done the performance just does not improve. It is currently carefully
|
213
|
+
constructed to make sure that it gets the best possible performance, but
|
214
|
+
anyone who thinks they can make it faster is more than welcome to take a
|
215
|
+
crack at it.
|
260
216
|
</p>
|
261
217
|
</div>
|
262
218
|
</div>
|
263
219
|
|
264
|
-
<div id="method-
|
265
|
-
<a name="
|
220
|
+
<div id="method-M000015" class="method-detail">
|
221
|
+
<a name="M000015"></a>
|
266
222
|
|
267
223
|
<div class="method-heading">
|
268
|
-
<a href="HttpServer.src/
|
269
|
-
onclick="popupCode('HttpServer.src/
|
224
|
+
<a href="HttpServer.src/M000015.html" target="Code" class="method-signature"
|
225
|
+
onclick="popupCode('HttpServer.src/M000015.html');return false;">
|
270
226
|
<span class="method-name">register</span><span class="method-args">(uri, handler)</span>
|
271
227
|
</a>
|
272
228
|
</div>
|
@@ -277,18 +233,18 @@ Simply registers a handler with the internal <a
|
|
277
233
|
href="URIClassifier.html">URIClassifier</a>. When the URI is found in the
|
278
234
|
prefix of a request then your handler’s HttpHandler::process method
|
279
235
|
is called. See <a
|
280
|
-
href="URIClassifier.html#
|
236
|
+
href="URIClassifier.html#M000020">Mongrel::URIClassifier#register</a> for
|
281
237
|
more information.
|
282
238
|
</p>
|
283
239
|
</div>
|
284
240
|
</div>
|
285
241
|
|
286
|
-
<div id="method-
|
287
|
-
<a name="
|
242
|
+
<div id="method-M000014" class="method-detail">
|
243
|
+
<a name="M000014"></a>
|
288
244
|
|
289
245
|
<div class="method-heading">
|
290
|
-
<a href="HttpServer.src/
|
291
|
-
onclick="popupCode('HttpServer.src/
|
246
|
+
<a href="HttpServer.src/M000014.html" target="Code" class="method-signature"
|
247
|
+
onclick="popupCode('HttpServer.src/M000014.html');return false;">
|
292
248
|
<span class="method-name">run</span><span class="method-args">()</span>
|
293
249
|
</a>
|
294
250
|
</div>
|
@@ -302,12 +258,12 @@ later.
|
|
302
258
|
</div>
|
303
259
|
</div>
|
304
260
|
|
305
|
-
<div id="method-
|
306
|
-
<a name="
|
261
|
+
<div id="method-M000016" class="method-detail">
|
262
|
+
<a name="M000016"></a>
|
307
263
|
|
308
264
|
<div class="method-heading">
|
309
|
-
<a href="HttpServer.src/
|
310
|
-
onclick="popupCode('HttpServer.src/
|
265
|
+
<a href="HttpServer.src/M000016.html" target="Code" class="method-signature"
|
266
|
+
onclick="popupCode('HttpServer.src/M000016.html');return false;">
|
311
267
|
<span class="method-name">unregister</span><span class="method-args">(uri)</span>
|
312
268
|
</a>
|
313
269
|
</div>
|
@@ -315,7 +271,7 @@ later.
|
|
315
271
|
<div class="method-description">
|
316
272
|
<p>
|
317
273
|
Removes any handler registered at the given URI. See <a
|
318
|
-
href="URIClassifier.html#
|
274
|
+
href="URIClassifier.html#M000021">Mongrel::URIClassifier#unregister</a> for
|
319
275
|
more information.
|
320
276
|
</p>
|
321
277
|
</div>
|
@@ -5,14 +5,27 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>new (Mongrel::HttpServer)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 303</span>
|
14
|
+
303: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">num_processors</span>=<span class="ruby-value">20</span>)
|
15
|
+
304: <span class="ruby-ivar">@socket</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>)
|
16
|
+
305:
|
17
|
+
306: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
|
18
|
+
307: <span class="ruby-ivar">@req_queue</span> = <span class="ruby-constant">Queue</span>.<span class="ruby-identifier">new</span>
|
19
|
+
308: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
20
|
+
309: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
21
|
+
310: <span class="ruby-ivar">@num_procesors</span> = <span class="ruby-identifier">num_processors</span>
|
22
|
+
311:
|
23
|
+
312: <span class="ruby-identifier">num_processors</span>.<span class="ruby-identifier">times</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
24
|
+
313: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">client</span> = <span class="ruby-ivar">@req_queue</span>.<span class="ruby-identifier">deq</span>
|
25
|
+
314: <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
|
26
|
+
315: <span class="ruby-keyword kw">end</span>
|
27
|
+
316: <span class="ruby-keyword kw">end</span>
|
28
|
+
317: }
|
29
|
+
318: <span class="ruby-keyword kw">end</span></pre>
|
17
30
|
</body>
|
18
31
|
</html>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>process_client (Mongrel::HttpServer)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 326</span>
|
14
|
+
326: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
|
15
|
+
327: <span class="ruby-keyword kw">begin</span>
|
16
|
+
328: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
|
17
|
+
329: <span class="ruby-identifier">params</span> = {}
|
18
|
+
330: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CHUNK_SIZE</span>)
|
19
|
+
331:
|
20
|
+
332: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
21
|
+
333: <span class="ruby-identifier">nread</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">data</span>)
|
22
|
+
334: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
|
23
|
+
335: <span class="ruby-identifier">script_name</span>, <span class="ruby-identifier">path_info</span>, <span class="ruby-identifier">handler</span> = <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">resolve</span>(<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">REQUEST_URI</span>])
|
24
|
+
336:
|
25
|
+
337: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handler</span>
|
26
|
+
338: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_INFO</span>] = <span class="ruby-identifier">path_info</span>
|
27
|
+
339: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SCRIPT_NAME</span>] = <span class="ruby-identifier">script_name</span>
|
28
|
+
340: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GATEWAY_INTERFACE</span>]=<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GATEWAY_INTERFACE_VALUE</span>
|
29
|
+
341: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">REMOTE_ADDR</span>]=<span class="ruby-identifier">client</span>.<span class="ruby-identifier">peeraddr</span>
|
30
|
+
342: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SERVER_NAME</span>]=<span class="ruby-ivar">@host</span>
|
31
|
+
343: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SERVER_PORT</span>]=<span class="ruby-ivar">@port</span>
|
32
|
+
344: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SERVER_PROTOCOL</span>]=<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SERVER_PROTOCOL_VALUE</span>
|
33
|
+
345: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SERVER_SOFTWARE</span>]=<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MONGREL_VERSION</span>
|
34
|
+
346:
|
35
|
+
347: <span class="ruby-identifier">request</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">data</span>[<span class="ruby-identifier">nread</span> <span class="ruby-operator">...</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>], <span class="ruby-identifier">client</span>)
|
36
|
+
348: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>)
|
37
|
+
349: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
38
|
+
350: <span class="ruby-keyword kw">else</span>
|
39
|
+
351: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR_404_RESPONSE</span>)
|
40
|
+
352: <span class="ruby-keyword kw">end</span>
|
41
|
+
353:
|
42
|
+
354: <span class="ruby-keyword kw">break</span>
|
43
|
+
355: <span class="ruby-keyword kw">else</span>
|
44
|
+
356: <span class="ruby-comment cmt"># gotta stream and read again until we can get the parser to be character safe</span>
|
45
|
+
357: <span class="ruby-comment cmt"># TODO: make this more efficient since this means we're parsing a lot repeatedly</span>
|
46
|
+
358: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">reset</span>
|
47
|
+
359: <span class="ruby-identifier">data</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CHUNK_SIZE</span>)
|
48
|
+
360: <span class="ruby-keyword kw">end</span>
|
49
|
+
361: <span class="ruby-keyword kw">end</span>
|
50
|
+
362: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>
|
51
|
+
363: <span class="ruby-comment cmt"># ignored</span>
|
52
|
+
364: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNRESET</span>
|
53
|
+
365: <span class="ruby-comment cmt"># ignored</span>
|
54
|
+
366: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPIPE</span>
|
55
|
+
367: <span class="ruby-comment cmt"># ignored</span>
|
56
|
+
368: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">details</span>
|
57
|
+
369: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR(#{details.class}): #{details}"</span>
|
58
|
+
370: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
59
|
+
371: <span class="ruby-keyword kw">ensure</span>
|
60
|
+
372: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
61
|
+
373: <span class="ruby-keyword kw">end</span>
|
62
|
+
374: <span class="ruby-keyword kw">end</span></pre>
|
63
|
+
</body>
|
64
|
+
</html>
|
@@ -10,13 +10,14 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 378</span>
|
14
|
+
378: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
|
15
|
+
379: <span class="ruby-constant">BasicSocket</span>.<span class="ruby-identifier">do_not_reverse_lookup</span>=<span class="ruby-keyword kw">true</span>
|
16
|
+
380: <span class="ruby-ivar">@acceptor</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
17
|
+
381: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
18
|
+
382: <span class="ruby-ivar">@req_queue</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">accept</span>
|
19
|
+
383: <span class="ruby-keyword kw">end</span>
|
20
|
+
384: <span class="ruby-keyword kw">end</span>
|
21
|
+
385: <span class="ruby-keyword kw">end</span></pre>
|
21
22
|
</body>
|
22
23
|
</html>
|
@@ -10,9 +10,9 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 391</span>
|
14
|
+
391: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>)
|
15
|
+
392: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>)
|
16
|
+
393: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>unregister (Mongrel::HttpServer)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 397</span>
|
14
|
+
397: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
15
|
+
398: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
16
|
+
399: <span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -86,10 +86,10 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
89
|
+
<a href="#M000019">new</a>
|
90
|
+
<a href="#M000020">register</a>
|
91
|
+
<a href="#M000022">resolve</a>
|
92
|
+
<a href="#M000021">unregister</a>
|
93
93
|
</div>
|
94
94
|
</div>
|
95
95
|
|
@@ -111,12 +111,12 @@
|
|
111
111
|
<div id="methods">
|
112
112
|
<h3 class="section-bar">Public Class methods</h3>
|
113
113
|
|
114
|
-
<div id="method-
|
115
|
-
<a name="
|
114
|
+
<div id="method-M000019" class="method-detail">
|
115
|
+
<a name="M000019"></a>
|
116
116
|
|
117
117
|
<div class="method-heading">
|
118
|
-
<a href="URIClassifier.src/
|
119
|
-
onclick="popupCode('URIClassifier.src/
|
118
|
+
<a href="URIClassifier.src/M000019.html" target="Code" class="method-signature"
|
119
|
+
onclick="popupCode('URIClassifier.src/M000019.html');return false;">
|
120
120
|
<span class="method-name">URIClassifier.new → URIClassifier<br />
|
121
121
|
</span>
|
122
122
|
</a>
|
@@ -143,12 +143,12 @@ portion.
|
|
143
143
|
|
144
144
|
<h3 class="section-bar">Public Instance methods</h3>
|
145
145
|
|
146
|
-
<div id="method-
|
147
|
-
<a name="
|
146
|
+
<div id="method-M000020" class="method-detail">
|
147
|
+
<a name="M000020"></a>
|
148
148
|
|
149
149
|
<div class="method-heading">
|
150
|
-
<a href="URIClassifier.src/
|
151
|
-
onclick="popupCode('URIClassifier.src/
|
150
|
+
<a href="URIClassifier.src/M000020.html" target="Code" class="method-signature"
|
151
|
+
onclick="popupCode('URIClassifier.src/M000020.html');return false;">
|
152
152
|
<span class="method-name">uc.register("/someuri", SampleHandler.new) → nil<br />
|
153
153
|
</span>
|
154
154
|
</a>
|
@@ -159,8 +159,9 @@ portion.
|
|
159
159
|
Registers the SampleHandler (one for all requests) with the
|
160
160
|
"/someuri". When URIClassifier::resolve is called with
|
161
161
|
"/someuri" it’ll return SampleHandler immediately. When
|
162
|
-
"/someuri/
|
163
|
-
|
162
|
+
called with "/someuri/iwant" it’ll also return SomeHandler
|
163
|
+
immediatly, with no additional searches, but it will return path info with
|
164
|
+
"/iwant".
|
164
165
|
</p>
|
165
166
|
<p>
|
166
167
|
You actually can reuse this class to register nearly anything and quickly
|
@@ -172,12 +173,12 @@ to get right with a Hash.
|
|
172
173
|
</div>
|
173
174
|
</div>
|
174
175
|
|
175
|
-
<div id="method-
|
176
|
-
<a name="
|
176
|
+
<div id="method-M000022" class="method-detail">
|
177
|
+
<a name="M000022"></a>
|
177
178
|
|
178
179
|
<div class="method-heading">
|
179
|
-
<a href="URIClassifier.src/
|
180
|
-
onclick="popupCode('URIClassifier.src/
|
180
|
+
<a href="URIClassifier.src/M000022.html" target="Code" class="method-signature"
|
181
|
+
onclick="popupCode('URIClassifier.src/M000022.html');return false;">
|
181
182
|
<span class="method-name">uc.resolve("/someuri") → "/someuri", "", handler<br />
|
182
183
|
uc.resolve("/someuri/pathinfo") → "/someuri", "/pathinfo", handler<br />
|
183
184
|
uc.resolve("/notfound/orhere") → nil, nil, nil<br />
|
@@ -208,17 +209,18 @@ chars, anything really. It also means that it’s very efficient to do
|
|
208
209
|
this only taking as long as the URI has characters.
|
209
210
|
</p>
|
210
211
|
<p>
|
211
|
-
It expects strings
|
212
|
+
It expects strings with no embedded ’\0’ characters.
|
213
|
+
Don‘t try other string-line stuff yet.
|
212
214
|
</p>
|
213
215
|
</div>
|
214
216
|
</div>
|
215
217
|
|
216
|
-
<div id="method-
|
217
|
-
<a name="
|
218
|
+
<div id="method-M000021" class="method-detail">
|
219
|
+
<a name="M000021"></a>
|
218
220
|
|
219
221
|
<div class="method-heading">
|
220
|
-
<a href="URIClassifier.src/
|
221
|
-
onclick="popupCode('URIClassifier.src/
|
222
|
+
<a href="URIClassifier.src/M000021.html" target="Code" class="method-signature"
|
223
|
+
onclick="popupCode('URIClassifier.src/M000021.html');return false;">
|
222
224
|
<span class="method-name">uc.unregister("/someuri")<br />
|
223
225
|
</span>
|
224
226
|
</a>
|