mongrel 0.3.12 → 0.3.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/Rakefile +1 -1
  2. data/bin/mongrel_rails +12 -6
  3. data/doc/rdoc/classes/Class.src/M000001.html +10 -10
  4. data/doc/rdoc/classes/Class.src/M000002.html +46 -46
  5. data/doc/rdoc/classes/Class.src/M000003.html +7 -7
  6. data/doc/rdoc/classes/Class.src/M000004.html +6 -6
  7. data/doc/rdoc/classes/IO.src/M000005.html +5 -5
  8. data/doc/rdoc/classes/IO.src/M000006.html +5 -5
  9. data/doc/rdoc/classes/Kernel.src/M000025.html +5 -5
  10. data/doc/rdoc/classes/Kernel.src/M000026.html +11 -11
  11. data/doc/rdoc/classes/Mongrel.html +1 -0
  12. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +1 -1
  13. data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +10 -10
  14. data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +9 -9
  15. data/doc/rdoc/classes/Mongrel/Configurator.src/M000101.html +4 -4
  16. data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +18 -18
  17. data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +5 -5
  18. data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +16 -16
  19. data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +19 -19
  20. data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +4 -4
  21. data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +10 -11
  22. data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +5 -5
  23. data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +8 -8
  24. data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +7 -7
  25. data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +4 -4
  26. data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +14 -13
  27. data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +5 -33
  28. data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +33 -5
  29. data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +18 -0
  30. data/doc/rdoc/classes/Mongrel/Const.html +11 -1
  31. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000116.html +5 -5
  32. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000117.html +18 -0
  33. data/doc/rdoc/classes/Mongrel/HeaderOut.html +0 -185
  34. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000072.html +4 -4
  35. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000073.html +4 -4
  36. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +3 -1
  37. data/doc/rdoc/classes/Mongrel/{StopServer.html → HttpParserError.html} +5 -11
  38. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000118.html +15 -7
  39. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000119.html +7 -7
  40. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000120.html +7 -19
  41. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000121.html +32 -0
  42. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +12 -12
  43. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +6 -6
  44. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +11 -11
  45. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +8 -8
  46. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +8 -8
  47. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +9 -9
  48. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +4 -4
  49. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +6 -6
  50. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +4 -4
  51. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +10 -10
  52. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +51 -50
  53. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +10 -10
  54. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +45 -45
  55. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +14 -14
  56. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +4 -4
  57. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +8 -8
  58. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +4 -4
  59. data/doc/rdoc/classes/ObjectTracker.src/M000019.html +20 -22
  60. data/doc/rdoc/classes/RequestLog/Access.src/M000122.html +19 -0
  61. data/doc/rdoc/classes/RequestLog/Files.src/{M000121.html → M000123.html} +5 -5
  62. data/doc/rdoc/classes/RequestLog/Objects.src/{M000122.html → M000124.html} +5 -5
  63. data/doc/rdoc/classes/RequestLog/Params.src/{M000123.html → M000125.html} +5 -5
  64. data/doc/rdoc/classes/Stats.html +1 -1
  65. data/doc/rdoc/classes/Stats.src/M000012.html +2 -2
  66. data/doc/rdoc/created.rid +1 -1
  67. data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
  68. data/doc/rdoc/files/lib/mongrel/command_rb.html +1 -1
  69. data/doc/rdoc/files/lib/mongrel/debug_rb.html +1 -1
  70. data/doc/rdoc/files/lib/mongrel/handlers_rb.html +1 -1
  71. data/doc/rdoc/files/lib/mongrel/stats_rb.html +1 -1
  72. data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
  73. data/examples/random_thrash.rb +19 -0
  74. data/ext/http11/http11.c +57 -12
  75. data/ext/http11/http11_parser.c +58 -52
  76. data/lib/mongrel.rb +37 -10
  77. data/lib/mongrel/command.rb +1 -1
  78. data/lib/mongrel/debug.rb +39 -125
  79. data/lib/mongrel/handlers.rb +2 -2
  80. data/lib/mongrel/rails.rb +2 -1
  81. data/lib/mongrel/stats.rb +2 -2
  82. data/test/test_configurator.rb +2 -2
  83. data/test/test_debug.rb +2 -4
  84. data/test/test_http11.rb +76 -7
  85. data/test/test_stats.rb +6 -4
  86. data/test/test_uriclassifier.rb +0 -14
  87. metadata +12 -24
  88. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +0 -383
  89. data/doc/rdoc/classes/Mongrel/Configurator.html +0 -563
  90. data/doc/rdoc/classes/Mongrel/Error404Handler.html +0 -171
  91. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000115.html +0 -18
  92. data/doc/rdoc/classes/Mongrel/HttpHandler.html +0 -152
  93. data/doc/rdoc/classes/Mongrel/HttpRequest.html +0 -222
  94. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000117.html +0 -28
  95. data/doc/rdoc/classes/Mongrel/HttpResponse.html +0 -371
  96. data/doc/rdoc/classes/Mongrel/URIClassifier.html +0 -301
  97. data/doc/rdoc/classes/RequestLog.html +0 -113
  98. data/doc/rdoc/classes/RequestLog/Files.html +0 -144
  99. data/doc/rdoc/classes/RequestLog/Objects.html +0 -144
  100. data/doc/rdoc/classes/RequestLog/Params.html +0 -144
  101. data/doc/rdoc/fr_class_index.html +0 -60
  102. data/doc/rdoc/fr_file_index.html +0 -40
  103. data/doc/rdoc/fr_method_index.html +0 -149
  104. data/doc/rdoc/index.html +0 -24
  105. data/lib/http11.bundle +0 -0
@@ -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 210</span>
14
- 210: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
- 211: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
- 212: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 212</span>
14
+ 212: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
+ 213: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
+ 214: <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 215</span>
14
- 215: <span class="ruby-keyword kw">def</span><span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span>)
15
- 216: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HEADER_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>])
16
- 217: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 217</span>
14
+ 217: <span class="ruby-keyword kw">def</span><span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span>)
15
+ 218: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HEADER_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>])
16
+ 219: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -31,8 +31,10 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data)
31
31
  http-&gt;data = (void *)req_hash;
32
32
  http_parser_execute(http, RSTRING(data)-&gt;ptr, RSTRING(data)-&gt;len);
33
33
 
34
+ VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
35
+
34
36
  if(http_parser_has_error(http)) {
35
- rb_raise(rb_eStandardError, &quot;HTTP Parsing failure&quot;);
37
+ rb_raise(eHttpParserError, &quot;Invalid HTTP format, parsing fails.&quot;);
36
38
  } else {
37
39
  return INT2FIX(http_parser_nread(http));
38
40
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
7
  <head>
8
- <title>Class: Mongrel::StopServer</title>
8
+ <title>Class: Mongrel::HttpParserError</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
11
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
@@ -50,13 +50,13 @@
50
50
  <table class="header-table">
51
51
  <tr class="top-aligned-row">
52
52
  <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Mongrel::StopServer</td>
53
+ <td class="class-name-in-header">Mongrel::HttpParserError</td>
54
54
  </tr>
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../../files/lib/mongrel_rb.html">
59
- lib/mongrel.rb
58
+ <a href="../../files/ext/http11/http11_c.html">
59
+ ext/http11/http11.c
60
60
  </a>
61
61
  <br />
62
62
  </td>
@@ -65,7 +65,7 @@
65
65
  <tr class="top-aligned-row">
66
66
  <td><strong>Parent:</strong></td>
67
67
  <td>
68
- Exception
68
+ IOError
69
69
  </td>
70
70
  </tr>
71
71
  </table>
@@ -78,12 +78,6 @@
78
78
 
79
79
  <div id="contextContent">
80
80
 
81
- <div id="description">
82
- <p>
83
- Used to stop the <a href="HttpServer.html">HttpServer</a> via Thread.raise.
84
- </p>
85
-
86
- </div>
87
81
 
88
82
 
89
83
  </div>
@@ -5,16 +5,24 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>escape (Mongrel::HttpRequest)</title>
8
+ <title>new (Mongrel::HttpRequest)</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 164</span>
14
- 164: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">s</span>)
15
- 165: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9_.-]+)/n</span>) {
16
- 166: <span class="ruby-value str">'%'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'H2'</span><span class="ruby-operator">*</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'%'</span>).<span class="ruby-identifier">upcase</span>
17
- 167: }.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'+'</span>)
18
- 168: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 152</span>
14
+ 152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">initial_body</span>, <span class="ruby-identifier">socket</span>)
15
+ 153: <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">initial_body</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>
16
+ 154: <span class="ruby-ivar">@params</span> = <span class="ruby-identifier">params</span>
17
+ 155: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span>
18
+ 156:
19
+ 157: <span class="ruby-comment cmt"># now, if the initial_body isn't long enough for the content length we have to fill it</span>
20
+ 158: <span class="ruby-comment cmt"># TODO: adapt for big ass stuff by writing to a temp file</span>
21
+ 159: <span class="ruby-identifier">clen</span> = <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span>
22
+ 160: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">clen</span>
23
+ 161: <span class="ruby-ivar">@body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">clen</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span>)
24
+ 162: <span class="ruby-keyword kw">end</span>
25
+ 163:
26
+ 164: <span class="ruby-keyword kw">end</span></pre>
19
27
  </body>
20
28
  </html>
@@ -5,16 +5,16 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>unescape (Mongrel::HttpRequest)</title>
8
+ <title>escape (Mongrel::HttpRequest)</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 171</span>
14
- 171: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">s</span>)
15
- 172: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'+'</span>, <span class="ruby-value str">' '</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/((?:%[0-9a-fA-F]{2})+)/n</span>){
16
- 173: [<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'%'</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">'H*'</span>)
17
- 174: }
18
- 175: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 166</span>
14
+ 166: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">s</span>)
15
+ 167: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9_.-]+)/n</span>) {
16
+ 168: <span class="ruby-value str">'%'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'H2'</span><span class="ruby-operator">*</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'%'</span>).<span class="ruby-identifier">upcase</span>
17
+ 169: }.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'+'</span>)
18
+ 170: <span class="ruby-keyword kw">end</span></pre>
19
19
  </body>
20
20
  </html>
@@ -5,28 +5,16 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>query_parse (Mongrel::HttpRequest)</title>
8
+ <title>unescape (Mongrel::HttpRequest)</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 178</span>
14
- 178: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query_parse</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">d</span> = <span class="ruby-value str">'&amp;;'</span>)
15
- 179: <span class="ruby-identifier">params</span> = {}
16
- 180: (<span class="ruby-identifier">qs</span><span class="ruby-operator">||</span><span class="ruby-value str">''</span>).<span class="ruby-identifier">split</span>(<span class="ruby-node">/[#{d}] */n</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">params</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
17
- 181: <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>=<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">p</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">'='</span>,<span class="ruby-value">2</span>)
18
- 182: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cur</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>]
19
- 183: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cur</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
20
- 184: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>
21
- 185: <span class="ruby-keyword kw">else</span>
22
- 186: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = [<span class="ruby-identifier">cur</span>, <span class="ruby-identifier">v</span>]
23
- 187: <span class="ruby-keyword kw">end</span>
24
- 188: <span class="ruby-keyword kw">else</span>
25
- 189: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
26
- 190: <span class="ruby-keyword kw">end</span>
27
- 191: }
28
- 192:
29
- 193: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">params</span>
30
- 194: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 173</span>
14
+ 173: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">s</span>)
15
+ 174: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'+'</span>, <span class="ruby-value str">' '</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/((?:%[0-9a-fA-F]{2})+)/n</span>){
16
+ 175: [<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'%'</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">'H*'</span>)
17
+ 176: }
18
+ 177: <span class="ruby-keyword kw">end</span></pre>
31
19
  </body>
32
20
  </html>
@@ -0,0 +1,32 @@
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>query_parse (Mongrel::HttpRequest)</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 180</span>
14
+ 180: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query_parse</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">d</span> = <span class="ruby-value str">'&amp;;'</span>)
15
+ 181: <span class="ruby-identifier">params</span> = {}
16
+ 182: (<span class="ruby-identifier">qs</span><span class="ruby-operator">||</span><span class="ruby-value str">''</span>).<span class="ruby-identifier">split</span>(<span class="ruby-node">/[#{d}] */n</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">params</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
17
+ 183: <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>=<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">p</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">'='</span>,<span class="ruby-value">2</span>)
18
+ 184: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cur</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>]
19
+ 185: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cur</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
20
+ 186: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>
21
+ 187: <span class="ruby-keyword kw">else</span>
22
+ 188: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = [<span class="ruby-identifier">cur</span>, <span class="ruby-identifier">v</span>]
23
+ 189: <span class="ruby-keyword kw">end</span>
24
+ 190: <span class="ruby-keyword kw">else</span>
25
+ 191: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
26
+ 192: <span class="ruby-keyword kw">end</span>
27
+ 193: }
28
+ 194:
29
+ 195: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">params</span>
30
+ 196: <span class="ruby-keyword kw">end</span></pre>
31
+ </body>
32
+ </html>
@@ -10,17 +10,17 @@
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 260</span>
14
- 260: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">socket</span>, <span class="ruby-identifier">filter</span> = <span class="ruby-keyword kw">nil</span>)
15
- 261: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span>
16
- 262: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
17
- 263: <span class="ruby-ivar">@status</span> = <span class="ruby-value">404</span>
18
- 264: <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
- 265: <span class="ruby-ivar">@header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">DATE</span>] = <span class="ruby-constant">HttpServer</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
20
- 266: <span class="ruby-ivar">@filter</span> = <span class="ruby-identifier">filter</span>
21
- 267: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">false</span>
22
- 268: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">false</span>
23
- 269: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">false</span>
24
- 270: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 262</span>
14
+ 262: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">socket</span>, <span class="ruby-identifier">filter</span> = <span class="ruby-keyword kw">nil</span>)
15
+ 263: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span>
16
+ 264: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
17
+ 265: <span class="ruby-ivar">@status</span> = <span class="ruby-value">404</span>
18
+ 266: <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
+ 267: <span class="ruby-ivar">@header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">DATE</span>] = <span class="ruby-constant">HttpServer</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
20
+ 268: <span class="ruby-ivar">@filter</span> = <span class="ruby-identifier">filter</span>
21
+ 269: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">false</span>
22
+ 270: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">false</span>
23
+ 271: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">false</span>
24
+ 272: <span class="ruby-keyword kw">end</span></pre>
25
25
  </body>
26
26
  </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 280</span>
14
- 280: <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>, <span class="ruby-identifier">finalize</span>=<span class="ruby-keyword kw">false</span>)
15
- 281: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
16
- 282: <span class="ruby-keyword kw">yield</span> <span class="ruby-ivar">@header</span>, <span class="ruby-ivar">@body</span>
17
- 283: <span class="ruby-identifier">finished</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalize</span>
18
- 284: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 282</span>
14
+ 282: <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>, <span class="ruby-identifier">finalize</span>=<span class="ruby-keyword kw">false</span>)
15
+ 283: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
16
+ 284: <span class="ruby-keyword kw">yield</span> <span class="ruby-ivar">@header</span>, <span class="ruby-ivar">@body</span>
17
+ 285: <span class="ruby-identifier">finished</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalize</span>
18
+ 286: <span class="ruby-keyword kw">end</span></pre>
19
19
  </body>
20
20
  </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 289</span>
14
- 289: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
15
- 290: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body_sent</span>
16
- 291: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;You have already sent the request body.&quot;</span>
17
- 292: <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@header_sent</span>
18
- 293: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;You have already sent the request headers.&quot;</span>
19
- 294: <span class="ruby-keyword kw">else</span>
20
- 295: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
21
- 296: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
22
- 297: <span class="ruby-keyword kw">end</span>
23
- 298: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 291</span>
14
+ 291: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
15
+ 292: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body_sent</span>
16
+ 293: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;You have already sent the request body.&quot;</span>
17
+ 294: <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@header_sent</span>
18
+ 295: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;You have already sent the request headers.&quot;</span>
19
+ 296: <span class="ruby-keyword kw">else</span>
20
+ 297: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
21
+ 298: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
22
+ 299: <span class="ruby-keyword kw">end</span>
23
+ 300: <span class="ruby-keyword kw">end</span></pre>
24
24
  </body>
25
25
  </html>
@@ -10,13 +10,13 @@
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 300</span>
14
- 300: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_status</span>(<span class="ruby-identifier">content_length</span>=<span class="ruby-keyword kw">nil</span>)
15
- 301: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@status_sent</span>
16
- 302: <span class="ruby-identifier">content_length</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span>
17
- 303: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">STATUS_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">status</span>, <span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-ivar">@status</span>], <span class="ruby-identifier">content_length</span>])
18
- 304: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">true</span>
19
- 305: <span class="ruby-keyword kw">end</span>
20
- 306: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 302</span>
14
+ 302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_status</span>(<span class="ruby-identifier">content_length</span>=<span class="ruby-keyword kw">nil</span>)
15
+ 303: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@status_sent</span>
16
+ 304: <span class="ruby-identifier">content_length</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span>
17
+ 305: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">STATUS_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">status</span>, <span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-ivar">@status</span>], <span class="ruby-identifier">content_length</span>])
18
+ 306: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">true</span>
19
+ 307: <span class="ruby-keyword kw">end</span>
20
+ 308: <span class="ruby-keyword kw">end</span></pre>
21
21
  </body>
22
22
  </html>
@@ -10,13 +10,13 @@
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 308</span>
14
- 308: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_header</span>
15
- 309: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@header_sent</span>
16
- 310: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
17
- 311: <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> <span class="ruby-operator">+</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LINE_END</span>)
18
- 312: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">true</span>
19
- 313: <span class="ruby-keyword kw">end</span>
20
- 314: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 310</span>
14
+ 310: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_header</span>
15
+ 311: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@header_sent</span>
16
+ 312: <span class="ruby-ivar">@header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
17
+ 313: <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> <span class="ruby-operator">+</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LINE_END</span>)
18
+ 314: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">true</span>
19
+ 315: <span class="ruby-keyword kw">end</span>
20
+ 316: <span class="ruby-keyword kw">end</span></pre>
21
21
  </body>
22
22
  </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 316</span>
14
- 316: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_body</span>
15
- 317: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@body_sent</span>
16
- 318: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
17
- 319: <span class="ruby-comment cmt"># connection: close is also added to ensure that the client does not pipeline.</span>
18
- 320: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@body</span>.<span class="ruby-identifier">read</span>)
19
- 321: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">true</span>
20
- 322: <span class="ruby-keyword kw">end</span>
21
- 323: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 318</span>
14
+ 318: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_body</span>
15
+ 319: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@body_sent</span>
16
+ 320: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
17
+ 321: <span class="ruby-comment cmt"># connection: close is also added to ensure that the client does not pipeline.</span>
18
+ 322: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@body</span>.<span class="ruby-identifier">read</span>)
19
+ 323: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">true</span>
20
+ 324: <span class="ruby-keyword kw">end</span>
21
+ 325: <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 325</span>
14
- 325: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
15
- 326: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
16
- 327: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 327</span>
14
+ 327: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
15
+ 328: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
16
+ 329: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </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 331</span>
14
- 331: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finished</span>
15
- 332: <span class="ruby-identifier">send_status</span>
16
- 333: <span class="ruby-identifier">send_header</span>
17
- 334: <span class="ruby-identifier">send_body</span>
18
- 335: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 333</span>
14
+ 333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finished</span>
15
+ 334: <span class="ruby-identifier">send_status</span>
16
+ 335: <span class="ruby-identifier">send_header</span>
17
+ 336: <span class="ruby-identifier">send_body</span>
18
+ 337: <span class="ruby-keyword kw">end</span></pre>
19
19
  </body>
20
20
  </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 337</span>
14
- 337: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done</span>
15
- 338: (<span class="ruby-ivar">@status_sent</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@header_sent</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@body_sent</span>)
16
- 339: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 339</span>
14
+ 339: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done</span>
15
+ 340: (<span class="ruby-ivar">@status_sent</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@header_sent</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@body_sent</span>)
16
+ 341: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -10,15 +10,15 @@
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 380</span>
14
- 380: <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">2</span><span class="ruby-operator">**</span><span class="ruby-value">30</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>), <span class="ruby-identifier">timeout</span>=<span class="ruby-value">0</span>)
15
- 381: <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
- 382: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
17
- 383: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
18
- 384: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
19
- 385: <span class="ruby-ivar">@workers</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
20
- 386: <span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">timeout</span>
21
- 387: <span class="ruby-ivar">@num_processors</span> = <span class="ruby-identifier">num_processors</span>
22
- 388: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 382</span>
14
+ 382: <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">2</span><span class="ruby-operator">**</span><span class="ruby-value">30</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>), <span class="ruby-identifier">timeout</span>=<span class="ruby-value">0</span>)
15
+ 383: <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
+ 384: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
17
+ 385: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
18
+ 386: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
19
+ 387: <span class="ruby-ivar">@workers</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
20
+ 388: <span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">timeout</span>
21
+ 389: <span class="ruby-ivar">@num_processors</span> = <span class="ruby-identifier">num_processors</span>
22
+ 390: <span class="ruby-keyword kw">end</span></pre>
23
23
  </body>
24
24
  </html>
@@ -10,56 +10,57 @@
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 396</span>
14
- 396: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
15
- 397: <span class="ruby-keyword kw">begin</span>
16
- 398: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
17
- 399: <span class="ruby-identifier">params</span> = {}
18
- 400:
19
- 401: <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>)
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 398</span>
14
+ 398: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
15
+ 399: <span class="ruby-keyword kw">begin</span>
16
+ 400: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
17
+ 401: <span class="ruby-identifier">params</span> = {}
20
18
  402:
21
- 403: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
22
- 404: <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>)
23
- 405:
24
- 406: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
25
- 407: <span class="ruby-identifier">script_name</span>, <span class="ruby-identifier">path_info</span>, <span class="ruby-identifier">handlers</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>])
26
- 408:
27
- 409: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handlers</span>
28
- 410: <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>
29
- 411: <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>
30
- 412:
31
- 413: <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>)
32
- 414: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>)
33
- 415:
34
- 416: <span class="ruby-identifier">handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
35
- 417: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
36
- 418: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span>
37
- 419: <span class="ruby-keyword kw">end</span>
38
- 420:
39
- 421: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span>
40
- 422: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">finished</span>
41
- 423: <span class="ruby-keyword kw">end</span>
42
- 424:
43
- 425: <span class="ruby-keyword kw">else</span>
44
- 426: <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>)
45
- 427: <span class="ruby-keyword kw">end</span>
46
- 428:
47
- 429: <span class="ruby-keyword kw">break</span> <span class="ruby-comment cmt">#done</span>
48
- 430: <span class="ruby-keyword kw">else</span>
49
- 431: <span class="ruby-comment cmt"># gotta stream and read again until we can get the parser to be character safe</span>
50
- 432: <span class="ruby-comment cmt"># TODO: make this more efficient since this means we're parsing a lot repeatedly</span>
51
- 433: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">reset</span>
52
- 434: <span class="ruby-identifier">data</span> <span class="ruby-operator">&lt;&lt;</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>)
53
- 435: <span class="ruby-keyword kw">end</span>
54
- 436: <span class="ruby-keyword kw">end</span>
55
- 437: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNRESET</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPIPE</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EINVAL</span>
56
- 438: <span class="ruby-comment cmt"># ignored</span>
57
- 439: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
58
- 440: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;ERROR(#{details.class}): #{details}&quot;</span>
59
- 441: <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">&quot;\n&quot;</span>)
60
- 442: <span class="ruby-keyword kw">ensure</span>
61
- 443: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
62
- 444: <span class="ruby-keyword kw">end</span>
63
- 445: <span class="ruby-keyword kw">end</span></pre>
19
+ 403: <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>)
20
+ 404:
21
+ 405: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
22
+ 406: <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>)
23
+ 407:
24
+ 408: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
25
+ 409: <span class="ruby-identifier">script_name</span>, <span class="ruby-identifier">path_info</span>, <span class="ruby-identifier">handlers</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>])
26
+ 410:
27
+ 411: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handlers</span>
28
+ 412: <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>
29
+ 413: <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>
30
+ 414: <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">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_X_FORWARDED_FOR</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">peeraddr</span>.<span class="ruby-identifier">last</span>
31
+ 415: <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>)
32
+ 416: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>)
33
+ 417:
34
+ 418: <span class="ruby-identifier">handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
35
+ 419: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
36
+ 420: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span>
37
+ 421: <span class="ruby-keyword kw">end</span>
38
+ 422:
39
+ 423: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span>
40
+ 424: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">finished</span>
41
+ 425: <span class="ruby-keyword kw">end</span>
42
+ 426:
43
+ 427: <span class="ruby-keyword kw">else</span>
44
+ 428: <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>)
45
+ 429: <span class="ruby-keyword kw">end</span>
46
+ 430:
47
+ 431: <span class="ruby-keyword kw">break</span> <span class="ruby-comment cmt">#done</span>
48
+ 432: <span class="ruby-keyword kw">else</span>
49
+ 433: <span class="ruby-comment cmt"># gotta stream and read again until we can get the parser to be character safe</span>
50
+ 434: <span class="ruby-comment cmt"># TODO: make this more efficient since this means we're parsing a lot repeatedly</span>
51
+ 435: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">reset</span>
52
+ 436: <span class="ruby-identifier">data</span> <span class="ruby-operator">&lt;&lt;</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>)
53
+ 437: <span class="ruby-keyword kw">end</span>
54
+ 438: <span class="ruby-keyword kw">end</span>
55
+ 439: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNRESET</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPIPE</span>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EINVAL</span>
56
+ 440: <span class="ruby-comment cmt"># ignored</span>
57
+ 441: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">HttpParserError</span>
58
+ 442: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;BAD CLIENT: #$!&quot;</span>
59
+ 443: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
60
+ 444: <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">&quot;\n&quot;</span>)
61
+ 445: <span class="ruby-keyword kw">ensure</span>
62
+ 446: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
63
+ 447: <span class="ruby-keyword kw">end</span>
64
+ 448: <span class="ruby-keyword kw">end</span></pre>
64
65
  </body>
65
66
  </html>