mongrel 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -1
- data/Rakefile +1 -1
- data/bin/mongrel_rails +77 -24
- data/doc/rdoc/classes/Mongrel.html +0 -30
- data/doc/rdoc/classes/Mongrel/DirHandler.html +45 -26
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000022.html +20 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000023.html +29 -7
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000024.html +27 -29
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000025.html +18 -27
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000026.html +25 -18
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000027.html +5 -25
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000047.html +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000048.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000022.html → M000015.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000016.html +6 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000017.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000018.html +20 -8
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000019.html +6 -20
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000020.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000021.html +6 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.html +1 -1
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000028.html +16 -9
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000029.html +49 -49
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000030.html +9 -9
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000031.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000032.html +4 -4
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +7 -2
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_method_index.html +15 -15
- data/lib/mongrel.rb +17 -8
- metadata +4 -5
- data/doc/rdoc/classes/Mongrel.src/M000015.html +0 -18
@@ -5,37 +5,23 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>error? (Mongrel::HttpParser)</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
13
|
<pre>/**
|
14
14
|
* call-seq:
|
15
|
-
* parser.
|
15
|
+
* parser.error? -> true/false
|
16
16
|
*
|
17
|
-
*
|
18
|
-
* returning an Integer to indicate how much of the data has been read. No matter
|
19
|
-
* what the return value, you should call HttpParser#finished? and HttpParser#error?
|
20
|
-
* to figure out if it's done parsing or there was an error.
|
21
|
-
*
|
22
|
-
* This function now throws an exception when there is a parsing error. This makes
|
23
|
-
* the logic for working with the parser much easier. You can still test for an
|
24
|
-
* error, but now you need to wrap the parser with an exception handling block.
|
17
|
+
* Tells you whether the parser is in an error state.
|
25
18
|
*/
|
26
|
-
VALUE
|
19
|
+
VALUE HttpParser_has_error(VALUE self)
|
27
20
|
{
|
28
21
|
http_parser *http = NULL;
|
29
22
|
DATA_GET(self, http_parser, http);
|
30
|
-
|
31
|
-
http
|
32
|
-
http_parser_execute(http, RSTRING(data)->ptr, RSTRING(data)->len);
|
33
|
-
|
34
|
-
if(http_parser_has_error(http)) {
|
35
|
-
rb_raise(rb_eStandardError, "HTTP Parsing failure");
|
36
|
-
} else {
|
37
|
-
return INT2FIX(http_parser_nread(http));
|
38
|
-
}
|
23
|
+
|
24
|
+
return http_parser_has_error(http) ? Qtrue : Qfalse;
|
39
25
|
}</pre>
|
40
26
|
</body>
|
41
27
|
</html>
|
@@ -5,23 +5,23 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>finished? (Mongrel::HttpParser)</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
13
|
<pre>/**
|
14
14
|
* call-seq:
|
15
|
-
* parser.
|
15
|
+
* parser.finished? -> true/false
|
16
16
|
*
|
17
|
-
* Tells you whether the parser is in
|
17
|
+
* Tells you whether the parser is finished or not and in a good state.
|
18
18
|
*/
|
19
|
-
VALUE
|
19
|
+
VALUE HttpParser_is_finished(VALUE self)
|
20
20
|
{
|
21
21
|
http_parser *http = NULL;
|
22
22
|
DATA_GET(self, http_parser, http);
|
23
23
|
|
24
|
-
return
|
24
|
+
return http_parser_is_finished(http) ? Qtrue : Qfalse;
|
25
25
|
}</pre>
|
26
26
|
</body>
|
27
27
|
</html>
|
@@ -5,23 +5,24 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>nread (Mongrel::HttpParser)</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
13
|
<pre>/**
|
14
14
|
* call-seq:
|
15
|
-
* parser.
|
15
|
+
* parser.nread -> Integer
|
16
16
|
*
|
17
|
-
*
|
17
|
+
* Returns the amount of data processed so far during this processing cycle. It is
|
18
|
+
* set to 0 on initialize or reset calls and is incremented each time execute is called.
|
18
19
|
*/
|
19
|
-
VALUE
|
20
|
+
VALUE HttpParser_nread(VALUE self)
|
20
21
|
{
|
21
22
|
http_parser *http = NULL;
|
22
23
|
DATA_GET(self, http_parser, http);
|
23
24
|
|
24
|
-
return
|
25
|
+
return INT2FIX(http->nread);
|
25
26
|
}</pre>
|
26
27
|
</body>
|
27
28
|
</html>
|
@@ -164,7 +164,7 @@ finally useful.
|
|
164
164
|
<div class="method-heading">
|
165
165
|
<a href="HttpServer.src/M000028.html" target="Code" class="method-signature"
|
166
166
|
onclick="popupCode('HttpServer.src/M000028.html');return false;">
|
167
|
-
<span class="method-name">new</span><span class="method-args">(host, port, num_processors=20)</span>
|
167
|
+
<span class="method-name">new</span><span class="method-args">(host, port, num_processors=20, timeout=120)</span>
|
168
168
|
</a>
|
169
169
|
</div>
|
170
170
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
13
|
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 317</span>
|
14
|
-
317: <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>)
|
14
|
+
317: <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>, <span class="ruby-identifier">timeout</span>=<span class="ruby-value">120</span>)
|
15
15
|
318: <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
16
|
319:
|
17
17
|
320: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
|
@@ -19,13 +19,20 @@
|
|
19
19
|
322: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
20
20
|
323: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
21
21
|
324: <span class="ruby-ivar">@num_processors</span> = <span class="ruby-identifier">num_processors</span>
|
22
|
-
325:
|
23
|
-
326:
|
24
|
-
327:
|
25
|
-
328:
|
26
|
-
329:
|
27
|
-
330:
|
28
|
-
331:
|
29
|
-
332:
|
22
|
+
325: <span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">timeout</span>
|
23
|
+
326:
|
24
|
+
327: <span class="ruby-ivar">@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>
|
25
|
+
328: <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>
|
26
|
+
329: <span class="ruby-keyword kw">begin</span>
|
27
|
+
330: <span class="ruby-constant">Timeout</span>.<span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@timeout</span>) <span class="ruby-keyword kw">do</span>
|
28
|
+
331: <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
|
29
|
+
332: <span class="ruby-keyword kw">end</span>
|
30
|
+
333: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
|
31
|
+
334: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"WARNING: Request took longer than #@timeout second timeout"</span>
|
32
|
+
335: <span class="ruby-keyword kw">end</span>
|
33
|
+
336: <span class="ruby-keyword kw">end</span>
|
34
|
+
337: <span class="ruby-keyword kw">end</span>
|
35
|
+
338: }
|
36
|
+
339: <span class="ruby-keyword kw">end</span></pre>
|
30
37
|
</body>
|
31
38
|
</html>
|
@@ -10,55 +10,55 @@
|
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
360:
|
35
|
-
361: <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
|
-
362: <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
|
-
363: <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
|
-
364: <span class="ruby-keyword kw">else</span>
|
39
|
-
365: <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
|
-
366: <span class="ruby-keyword kw">end</span>
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 347</span>
|
14
|
+
347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
|
15
|
+
348: <span class="ruby-keyword kw">begin</span>
|
16
|
+
349: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
|
17
|
+
350: <span class="ruby-identifier">params</span> = {}
|
18
|
+
351: <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
|
+
352:
|
20
|
+
353: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
21
|
+
354: <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
|
+
355: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
|
23
|
+
356: <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
|
+
357:
|
25
|
+
358: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handler</span>
|
26
|
+
359: <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
|
+
360: <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
|
+
361: <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
|
+
362: <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>[<span class="ruby-value">3</span>]
|
30
|
+
363: <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
|
+
364: <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
|
+
365: <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
|
+
366: <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>
|
41
34
|
367:
|
42
|
-
368:
|
43
|
-
369:
|
44
|
-
370:
|
45
|
-
371: <span class="ruby-
|
46
|
-
372:
|
47
|
-
373: <span class="ruby-
|
48
|
-
374:
|
49
|
-
375:
|
50
|
-
376:
|
51
|
-
377:
|
52
|
-
378:
|
53
|
-
379:
|
54
|
-
380:
|
55
|
-
381:
|
56
|
-
382:
|
57
|
-
383:
|
58
|
-
384: <span class="ruby-
|
59
|
-
385: <span class="ruby-keyword kw">
|
60
|
-
386: <span class="ruby-
|
61
|
-
387: <span class="ruby-keyword kw">
|
62
|
-
388:
|
35
|
+
368: <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
|
+
369: <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
|
+
370: <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
|
+
371: <span class="ruby-keyword kw">else</span>
|
39
|
+
372: <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
|
+
373: <span class="ruby-keyword kw">end</span>
|
41
|
+
374:
|
42
|
+
375: <span class="ruby-keyword kw">break</span>
|
43
|
+
376: <span class="ruby-keyword kw">else</span>
|
44
|
+
377: <span class="ruby-comment cmt"># gotta stream and read again until we can get the parser to be character safe</span>
|
45
|
+
378: <span class="ruby-comment cmt"># TODO: make this more efficient since this means we're parsing a lot repeatedly</span>
|
46
|
+
379: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">reset</span>
|
47
|
+
380: <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
|
+
381: <span class="ruby-keyword kw">end</span>
|
49
|
+
382: <span class="ruby-keyword kw">end</span>
|
50
|
+
383: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>
|
51
|
+
384: <span class="ruby-comment cmt"># ignored</span>
|
52
|
+
385: <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
|
+
386: <span class="ruby-comment cmt"># ignored</span>
|
54
|
+
387: <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
|
+
388: <span class="ruby-comment cmt"># ignored</span>
|
56
|
+
389: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">details</span>
|
57
|
+
390: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR(#{details.class}): #{details}"</span>
|
58
|
+
391: <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
|
+
392: <span class="ruby-keyword kw">ensure</span>
|
60
|
+
393: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
61
|
+
394: <span class="ruby-keyword kw">end</span>
|
62
|
+
395: <span class="ruby-keyword kw">end</span></pre>
|
63
63
|
</body>
|
64
64
|
</html>
|
@@ -10,14 +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
|
-
|
21
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 399</span>
|
14
|
+
399: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
|
15
|
+
400: <span class="ruby-constant">BasicSocket</span>.<span class="ruby-identifier">do_not_reverse_lookup</span>=<span class="ruby-keyword kw">true</span>
|
16
|
+
401: <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
|
+
402: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
18
|
+
403: <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
|
+
404: <span class="ruby-keyword kw">end</span>
|
20
|
+
405: <span class="ruby-keyword kw">end</span>
|
21
|
+
406: <span class="ruby-keyword kw">end</span></pre>
|
22
22
|
</body>
|
23
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 412</span>
|
14
|
+
412: <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
|
+
413: <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
|
+
414: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</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 418</span>
|
14
|
+
418: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
15
|
+
419: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
16
|
+
420: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Mon Feb 13 18:33:47 EST 2006
|
data/doc/rdoc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Feb 13 18:33:41 EST 2006</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -84,7 +84,7 @@ portability issues.
|
|
84
84
|
</p>
|
85
85
|
<h2>Status</h2>
|
86
86
|
<p>
|
87
|
-
The 0.3.
|
87
|
+
The 0.3.2 release supports Ruby On Rails much better than previously, and
|
88
88
|
also sports the beginning of a command and plugin infrastructure. This last
|
89
89
|
part isn’t documented yet.
|
90
90
|
</p>
|
@@ -121,6 +121,11 @@ And you can stop it whenever you like with:
|
|
121
121
|
All of which should be done from your application’s directory. It
|
122
122
|
writes the PID of the process you ran into log/mongrel.pid.
|
123
123
|
</p>
|
124
|
+
<p>
|
125
|
+
There are also many more new options for configuring the rails runner
|
126
|
+
including changing to a different directory, adding more MIME types, and
|
127
|
+
setting processor threads and timeouts.
|
128
|
+
</p>
|
124
129
|
<h2>Install</h2>
|
125
130
|
<p>
|
126
131
|
It doesn’t explicitly require Camping, but if you want to run the
|
@@ -21,18 +21,18 @@
|
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
23
|
<a href="classes/Mongrel/HeaderOut.html#M000034">[]= (Mongrel::HeaderOut)</a><br />
|
24
|
-
<a href="classes/Mongrel.html#
|
25
|
-
<a href="classes/Mongrel/DirHandler.html#
|
24
|
+
<a href="classes/Mongrel/DirHandler.html#M000027">add_mime_type (Mongrel::DirHandler)</a><br />
|
25
|
+
<a href="classes/Mongrel/DirHandler.html#M000023">can_serve (Mongrel::DirHandler)</a><br />
|
26
26
|
<a href="classes/PluginFactory.html#M000009">create (PluginFactory)</a><br />
|
27
27
|
<a href="classes/PluginFactory.html#M000008">derivativeClasses (PluginFactory)</a><br />
|
28
28
|
<a href="classes/PluginFactory.html#M000005">derivatives (PluginFactory)</a><br />
|
29
|
-
<a href="classes/Mongrel/HttpParser.html#
|
30
|
-
<a href="classes/Mongrel/HttpParser.html#
|
29
|
+
<a href="classes/Mongrel/HttpParser.html#M000019">error? (Mongrel::HttpParser)</a><br />
|
30
|
+
<a href="classes/Mongrel/HttpParser.html#M000018">execute (Mongrel::HttpParser)</a><br />
|
31
31
|
<a href="classes/PluginFactory.html#M000004">extend_object (PluginFactory)</a><br />
|
32
32
|
<a href="classes/PluginFactory.html#M000006">factoryType (PluginFactory)</a><br />
|
33
|
-
<a href="classes/Mongrel/HttpParser.html#
|
33
|
+
<a href="classes/Mongrel/HttpParser.html#M000017">finish (Mongrel::HttpParser)</a><br />
|
34
34
|
<a href="classes/Mongrel/HttpResponse.html#M000046">finished (Mongrel::HttpResponse)</a><br />
|
35
|
-
<a href="classes/Mongrel/HttpParser.html#
|
35
|
+
<a href="classes/Mongrel/HttpParser.html#M000020">finished? (Mongrel::HttpParser)</a><br />
|
36
36
|
<a href="classes/PluginFactory.html#M000012">getModuleName (PluginFactory)</a><br />
|
37
37
|
<a href="classes/PluginFactory.html#M000010">getSubclass (PluginFactory)</a><br />
|
38
38
|
<a href="classes/PluginFactory.html#M000003">included (PluginFactory)</a><br />
|
@@ -40,30 +40,30 @@
|
|
40
40
|
<a href="classes/PluginFactory.html#M000011">loadDerivative (PluginFactory)</a><br />
|
41
41
|
<a href="classes/PluginFactory.html#M000002">log (PluginFactory)</a><br />
|
42
42
|
<a href="classes/PluginFactory.html#M000014">makeRequirePath (PluginFactory)</a><br />
|
43
|
-
<a href="classes/
|
43
|
+
<a href="classes/Mongrel/HttpParser.html#M000015">new (Mongrel::HttpParser)</a><br />
|
44
|
+
<a href="classes/Mongrel/DirHandler.html#M000022">new (Mongrel::DirHandler)</a><br />
|
44
45
|
<a href="classes/Mongrel/HttpResponse.html#M000040">new (Mongrel::HttpResponse)</a><br />
|
45
|
-
<a href="classes/Mongrel/DirHandler.html#M000023">new (Mongrel::DirHandler)</a><br />
|
46
|
-
<a href="classes/Mongrel/HttpParser.html#M000016">new (Mongrel::HttpParser)</a><br />
|
47
|
-
<a href="classes/Mongrel/HeaderOut.html#M000033">new (Mongrel::HeaderOut)</a><br />
|
48
46
|
<a href="classes/Mongrel/URIClassifier.html#M000035">new (Mongrel::URIClassifier)</a><br />
|
47
|
+
<a href="classes/Mongrel/HeaderOut.html#M000033">new (Mongrel::HeaderOut)</a><br />
|
49
48
|
<a href="classes/Mongrel/Error404Handler.html#M000047">new (Mongrel::Error404Handler)</a><br />
|
49
|
+
<a href="classes/FactoryError.html#M000001">new (FactoryError)</a><br />
|
50
50
|
<a href="classes/Mongrel/HttpServer.html#M000028">new (Mongrel::HttpServer)</a><br />
|
51
51
|
<a href="classes/Mongrel/HttpRequest.html#M000049">new (Mongrel::HttpRequest)</a><br />
|
52
|
-
<a href="classes/Mongrel/HttpParser.html#
|
52
|
+
<a href="classes/Mongrel/HttpParser.html#M000021">nread (Mongrel::HttpParser)</a><br />
|
53
53
|
<a href="classes/Mongrel/Error404Handler.html#M000048">process (Mongrel::Error404Handler)</a><br />
|
54
54
|
<a href="classes/Mongrel/HttpHandler.html#M000039">process (Mongrel::HttpHandler)</a><br />
|
55
|
-
<a href="classes/Mongrel/DirHandler.html#
|
55
|
+
<a href="classes/Mongrel/DirHandler.html#M000026">process (Mongrel::DirHandler)</a><br />
|
56
56
|
<a href="classes/Mongrel/HttpServer.html#M000029">process_client (Mongrel::HttpServer)</a><br />
|
57
57
|
<a href="classes/Mongrel/HttpServer.html#M000031">register (Mongrel::HttpServer)</a><br />
|
58
58
|
<a href="classes/Mongrel/URIClassifier.html#M000036">register (Mongrel::URIClassifier)</a><br />
|
59
59
|
<a href="classes/PluginFactory.html#M000013">requireDerivative (PluginFactory)</a><br />
|
60
60
|
<a href="classes/Mongrel/HttpResponse.html#M000042">reset (Mongrel::HttpResponse)</a><br />
|
61
|
-
<a href="classes/Mongrel/HttpParser.html#
|
61
|
+
<a href="classes/Mongrel/HttpParser.html#M000016">reset (Mongrel::HttpParser)</a><br />
|
62
62
|
<a href="classes/Mongrel/URIClassifier.html#M000038">resolve (Mongrel::URIClassifier)</a><br />
|
63
63
|
<a href="classes/Mongrel/HttpServer.html#M000030">run (Mongrel::HttpServer)</a><br />
|
64
64
|
<a href="classes/Mongrel/HttpResponse.html#M000045">send_body (Mongrel::HttpResponse)</a><br />
|
65
|
-
<a href="classes/Mongrel/DirHandler.html#
|
66
|
-
<a href="classes/Mongrel/DirHandler.html#
|
65
|
+
<a href="classes/Mongrel/DirHandler.html#M000024">send_dir_listing (Mongrel::DirHandler)</a><br />
|
66
|
+
<a href="classes/Mongrel/DirHandler.html#M000025">send_file (Mongrel::DirHandler)</a><br />
|
67
67
|
<a href="classes/Mongrel/HttpResponse.html#M000044">send_header (Mongrel::HttpResponse)</a><br />
|
68
68
|
<a href="classes/Mongrel/HttpResponse.html#M000043">send_status (Mongrel::HttpResponse)</a><br />
|
69
69
|
<a href="classes/Mongrel/HttpResponse.html#M000041">start (Mongrel::HttpResponse)</a><br />
|
data/lib/mongrel.rb
CHANGED
@@ -314,7 +314,7 @@ module Mongrel
|
|
314
314
|
# try changing it higher. If you find that responses are way too slow
|
315
315
|
# try lowering it (after you've tuned your stuff of course).
|
316
316
|
# Future versions of Mongrel will make this more dynamic (hopefully).
|
317
|
-
def initialize(host, port, num_processors=20)
|
317
|
+
def initialize(host, port, num_processors=20, timeout=120)
|
318
318
|
@socket = TCPServer.new(host, port)
|
319
319
|
|
320
320
|
@classifier = URIClassifier.new
|
@@ -322,10 +322,17 @@ module Mongrel
|
|
322
322
|
@host = host
|
323
323
|
@port = port
|
324
324
|
@num_processors = num_processors
|
325
|
+
@timeout = timeout
|
325
326
|
|
326
327
|
@num_processors.times {|i| Thread.new do
|
327
328
|
while client = @req_queue.deq
|
328
|
-
|
329
|
+
begin
|
330
|
+
Timeout.timeout(@timeout) do
|
331
|
+
process_client(client)
|
332
|
+
end
|
333
|
+
rescue Timeout::Error
|
334
|
+
STDERR.puts "WARNING: Request took longer than #@timeout second timeout"
|
335
|
+
end
|
329
336
|
end
|
330
337
|
end
|
331
338
|
}
|
@@ -540,7 +547,7 @@ module Mongrel
|
|
540
547
|
end
|
541
548
|
end
|
542
549
|
|
543
|
-
open(req, "
|
550
|
+
open(req, "rb") do |f|
|
544
551
|
out.write(f.read)
|
545
552
|
end
|
546
553
|
end
|
@@ -572,12 +579,14 @@ module Mongrel
|
|
572
579
|
end
|
573
580
|
end
|
574
581
|
end
|
575
|
-
end
|
576
582
|
|
583
|
+
# There is a small number of default mime types for extensions, but
|
584
|
+
# this lets you add any others you'll need when serving content.
|
585
|
+
def DirHandler::add_mime_type(extension, type)
|
586
|
+
MIME_TYPES[extension] = type
|
587
|
+
end
|
577
588
|
|
578
|
-
# There is a small number of default mime types for extensions, but
|
579
|
-
# this lets you add any others you'll need when serving content.
|
580
|
-
def add_mime_type(extension, type)
|
581
|
-
MIME_TYPES[extension] = type
|
582
589
|
end
|
590
|
+
|
591
|
+
|
583
592
|
end
|