mongrel 0.3.13 → 0.3.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/Rakefile +1 -1
  2. data/bin/mongrel_rails +1 -1
  3. data/doc/rdoc/classes/Mongrel.html +1 -0
  4. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +49 -49
  5. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +11 -21
  6. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000099.html +34 -14
  7. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000100.html +21 -12
  8. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000101.html +14 -5
  9. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000102.html +12 -5
  10. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000103.html +5 -5
  11. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000104.html +5 -6
  12. data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000088.html → CGIWrapper.src/M000105.html} +5 -5
  13. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000106.html +19 -0
  14. data/doc/rdoc/classes/Mongrel/Camping.html +5 -5
  15. data/doc/rdoc/classes/Mongrel/Camping.src/{M000046.html → M000047.html} +0 -0
  16. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +10 -10
  17. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000048.html +5 -38
  18. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000049.html +51 -0
  19. data/doc/rdoc/classes/Mongrel/Command/Base.html +65 -65
  20. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +11 -29
  21. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +29 -5
  22. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +5 -5
  23. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +5 -5
  24. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +5 -5
  25. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +5 -9
  26. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +9 -5
  27. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +5 -5
  28. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +5 -5
  29. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +5 -11
  30. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +11 -11
  31. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +11 -5
  32. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +18 -0
  33. data/doc/rdoc/classes/Mongrel/Command/Registry.html +15 -15
  34. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000038.html +7 -12
  35. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +12 -37
  36. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000040.html +50 -0
  37. data/doc/rdoc/classes/Mongrel/Configurator.html +143 -107
  38. data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +16 -7
  39. data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +18 -7
  40. data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +7 -10
  41. data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +7 -5
  42. data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +10 -21
  43. data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +5 -6
  44. data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +21 -17
  45. data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +6 -20
  46. data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +17 -5
  47. data/doc/rdoc/classes/Mongrel/Configurator.src/M000116.html +20 -11
  48. data/doc/rdoc/classes/Mongrel/Configurator.src/M000117.html +5 -6
  49. data/doc/rdoc/classes/Mongrel/Configurator.src/M000118.html +11 -9
  50. data/doc/rdoc/classes/Mongrel/Configurator.src/M000119.html +6 -12
  51. data/doc/rdoc/classes/Mongrel/Configurator.src/M000120.html +5 -5
  52. data/doc/rdoc/classes/Mongrel/Configurator.src/M000121.html +9 -22
  53. data/doc/rdoc/classes/Mongrel/Configurator.src/M000122.html +12 -5
  54. data/doc/rdoc/classes/Mongrel/Configurator.src/M000123.html +5 -20
  55. data/doc/rdoc/classes/Mongrel/Configurator.src/M000124.html +22 -5
  56. data/doc/rdoc/classes/Mongrel/Configurator.src/M000125.html +18 -0
  57. data/doc/rdoc/classes/Mongrel/Configurator.src/M000126.html +33 -0
  58. data/doc/rdoc/classes/Mongrel/Configurator.src/M000127.html +18 -0
  59. data/doc/rdoc/classes/Mongrel/Const.html +6 -1
  60. data/doc/rdoc/classes/Mongrel/DeflateFilter.html +10 -10
  61. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000094.html → M000096.html} +5 -5
  62. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000095.html → M000097.html} +14 -14
  63. data/doc/rdoc/classes/Mongrel/DirHandler.html +31 -31
  64. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000057.html +8 -30
  65. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +30 -29
  66. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +29 -50
  67. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +50 -26
  68. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +26 -5
  69. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +18 -0
  70. data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
  71. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000125.html → M000128.html} +4 -4
  72. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000126.html → M000129.html} +4 -4
  73. data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
  74. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000070.html +5 -5
  75. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000071.html +18 -0
  76. data/doc/rdoc/classes/Mongrel/HttpHandler.html +31 -9
  77. data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000089.html → HttpHandler.src/M000076.html} +4 -5
  78. data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000075.html → M000077.html} +3 -3
  79. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +30 -15
  80. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000022.html +4 -6
  81. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000023.html +6 -4
  82. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000024.html +17 -0
  83. data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
  84. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000050.html +5 -6
  85. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +7 -7
  86. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +7 -37
  87. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +37 -5
  88. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +5 -5
  89. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +5 -6
  90. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000049.html → M000056.html} +6 -6
  91. data/doc/rdoc/classes/Mongrel/HttpRequest.html +20 -20
  92. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000130.html → M000135.html} +38 -38
  93. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000131.html → M000136.html} +6 -6
  94. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000132.html → M000137.html} +6 -6
  95. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000133.html → M000138.html} +18 -18
  96. data/doc/rdoc/classes/Mongrel/HttpResponse.html +61 -61
  97. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +12 -12
  98. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +7 -9
  99. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +12 -9
  100. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +9 -9
  101. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +9 -18
  102. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +9 -8
  103. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +18 -7
  104. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000085.html +8 -7
  105. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +7 -7
  106. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000087.html +7 -5
  107. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000088.html +20 -0
  108. data/doc/rdoc/classes/Mongrel/{HeaderOut.src/M000069.html → HttpResponse.src/M000089.html} +5 -5
  109. data/doc/rdoc/classes/Mongrel/HttpServer.html +38 -38
  110. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +12 -70
  111. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +76 -13
  112. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +13 -50
  113. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +50 -21
  114. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +20 -4
  115. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +5 -9
  116. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +22 -0
  117. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +15 -15
  118. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000041.html +26 -12
  119. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +12 -13
  120. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000043.html +26 -0
  121. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +15 -15
  122. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000044.html +9 -38
  123. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +38 -10
  124. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +23 -0
  125. data/doc/rdoc/classes/Mongrel/RedirectHandler.html +187 -0
  126. data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000133.html +22 -0
  127. data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000134.html +27 -0
  128. data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +16 -16
  129. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000127.html → M000130.html} +10 -10
  130. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000128.html → M000131.html} +10 -10
  131. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000129.html → M000132.html} +4 -4
  132. data/doc/rdoc/classes/Mongrel/StatusHandler.html +20 -20
  133. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000072.html +5 -11
  134. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000073.html +11 -29
  135. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000074.html +29 -7
  136. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000075.html +20 -0
  137. data/doc/rdoc/classes/Mongrel/URIClassifier.html +30 -30
  138. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000090.html +5 -26
  139. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000091.html +5 -38
  140. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +18 -15
  141. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000093.html +25 -57
  142. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000094.html +36 -0
  143. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000095.html +83 -0
  144. data/doc/rdoc/classes/RequestLog/Access.html +5 -5
  145. data/doc/rdoc/classes/RequestLog/Access.src/{M000134.html → M000139.html} +0 -0
  146. data/doc/rdoc/classes/RequestLog/Files.html +5 -5
  147. data/doc/rdoc/classes/RequestLog/Files.src/{M000135.html → M000140.html} +0 -0
  148. data/doc/rdoc/classes/RequestLog/Objects.html +5 -5
  149. data/doc/rdoc/classes/RequestLog/Objects.src/{M000137.html → M000142.html} +0 -0
  150. data/doc/rdoc/classes/RequestLog/Params.html +5 -5
  151. data/doc/rdoc/classes/RequestLog/Params.src/{M000138.html → M000143.html} +0 -0
  152. data/doc/rdoc/classes/RequestLog/Threads.html +5 -5
  153. data/doc/rdoc/classes/RequestLog/Threads.src/{M000136.html → M000141.html} +0 -0
  154. data/doc/rdoc/created.rid +1 -1
  155. data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
  156. data/doc/rdoc/files/lib/mongrel/handlers_rb.html +1 -1
  157. data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
  158. data/doc/rdoc/fr_class_index.html +1 -0
  159. data/doc/rdoc/fr_method_index.html +124 -119
  160. data/examples/simpletest.rb +2 -0
  161. data/ext/http11/http11.c +1 -1
  162. data/lib/mongrel.rb +30 -5
  163. data/lib/mongrel/handlers.rb +57 -2
  164. data/test/test_redirect_handler.rb +40 -0
  165. metadata +47 -38
  166. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000096.html +0 -24
  167. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000097.html +0 -47
  168. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000047.html +0 -18
  169. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +0 -24
  170. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000037.html +0 -20
  171. data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +0 -29
  172. data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +0 -31
  173. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +0 -21
  174. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +0 -25
  175. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +0 -20
  176. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +0 -25
  177. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000040.html +0 -39
  178. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000043.html +0 -22
  179. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +0 -18
@@ -5,16 +5,17 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>finished (Mongrel::HttpResponse)</title>
8
+ <title>socket_error (Mongrel::HttpResponse)</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 436</span>
14
- 436: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finished</span>
15
- 437: <span class="ruby-identifier">send_status</span>
16
- 438: <span class="ruby-identifier">send_header</span>
17
- 439: <span class="ruby-identifier">send_body</span>
18
- 440: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 422</span>
14
+ 422: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">socket_error</span>(<span class="ruby-identifier">details</span>)
15
+ 423: <span class="ruby-comment cmt"># ignore these since it means the client closed off early</span>
16
+ 424: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span>
17
+ 425: <span class="ruby-identifier">done</span> = <span class="ruby-keyword kw">true</span>
18
+ 426: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">details</span>
19
+ 427: <span class="ruby-keyword kw">end</span></pre>
19
20
  </body>
20
21
  </html>
@@ -5,16 +5,16 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>done= (Mongrel::HttpResponse)</title>
8
+ <title>write (Mongrel::HttpResponse)</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 444</span>
14
- 444: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done=</span>(<span class="ruby-identifier">val</span>)
15
- 445: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">true</span>
16
- 446: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">true</span>
17
- 447: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">true</span>
18
- 448: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 429</span>
14
+ 429: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
15
+ 430: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">data</span>)
16
+ 431: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
17
+ 432: <span class="ruby-identifier">socket_error</span>(<span class="ruby-identifier">details</span>)
18
+ 433: <span class="ruby-keyword kw">end</span></pre>
19
19
  </body>
20
20
  </html>
@@ -5,14 +5,16 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>done (Mongrel::HttpResponse)</title>
8
+ <title>finished (Mongrel::HttpResponse)</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 450</span>
14
- 450: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done</span>
15
- 451: (<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
- 452: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 437</span>
14
+ 437: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finished</span>
15
+ 438: <span class="ruby-identifier">send_status</span>
16
+ 439: <span class="ruby-identifier">send_header</span>
17
+ 440: <span class="ruby-identifier">send_body</span>
18
+ 441: <span class="ruby-keyword kw">end</span></pre>
17
19
  </body>
18
20
  </html>
@@ -0,0 +1,20 @@
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>done= (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 445</span>
14
+ 445: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done=</span>(<span class="ruby-identifier">val</span>)
15
+ 446: <span class="ruby-ivar">@status_sent</span> = <span class="ruby-keyword kw">true</span>
16
+ 447: <span class="ruby-ivar">@header_sent</span> = <span class="ruby-keyword kw">true</span>
17
+ 448: <span class="ruby-ivar">@body_sent</span> = <span class="ruby-keyword kw">true</span>
18
+ 449: <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -5,14 +5,14 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>new (Mongrel::HeaderOut)</title>
8
+ <title>done (Mongrel::HttpResponse)</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 283</span>
14
- 283: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
- 284: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
- 285: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 451</span>
14
+ 451: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">done</span>
15
+ 452: (<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
+ 453: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </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&#8217;s a very simple class that just has a
87
87
  thread accepting connections and a simple <a
88
- href="HttpServer.html#M000063">HttpServer.process_client</a> function to do
88
+ href="HttpServer.html#M000064">HttpServer.process_client</a> function to do
89
89
  the heavy lifting with the <a href="../IO.html">IO</a> and Ruby.
90
90
  </p>
91
91
  <p>
@@ -119,13 +119,13 @@ ways to make threads faster, but don&#8217;t hold your breath until Ruby
119
119
  <h3 class="section-bar">Methods</h3>
120
120
 
121
121
  <div class="name-list">
122
- <a href="#M000062">new</a>&nbsp;&nbsp;
123
- <a href="#M000063">process_client</a>&nbsp;&nbsp;
124
- <a href="#M000064">reap_dead_workers</a>&nbsp;&nbsp;
125
- <a href="#M000066">register</a>&nbsp;&nbsp;
126
- <a href="#M000065">run</a>&nbsp;&nbsp;
127
- <a href="#M000068">stop</a>&nbsp;&nbsp;
128
- <a href="#M000067">unregister</a>&nbsp;&nbsp;
122
+ <a href="#M000063">new</a>&nbsp;&nbsp;
123
+ <a href="#M000064">process_client</a>&nbsp;&nbsp;
124
+ <a href="#M000065">reap_dead_workers</a>&nbsp;&nbsp;
125
+ <a href="#M000067">register</a>&nbsp;&nbsp;
126
+ <a href="#M000066">run</a>&nbsp;&nbsp;
127
+ <a href="#M000069">stop</a>&nbsp;&nbsp;
128
+ <a href="#M000068">unregister</a>&nbsp;&nbsp;
129
129
  </div>
130
130
  </div>
131
131
 
@@ -190,12 +190,12 @@ ways to make threads faster, but don&#8217;t hold your breath until Ruby
190
190
  <div id="methods">
191
191
  <h3 class="section-bar">Public Class methods</h3>
192
192
 
193
- <div id="method-M000062" class="method-detail">
194
- <a name="M000062"></a>
193
+ <div id="method-M000063" class="method-detail">
194
+ <a name="M000063"></a>
195
195
 
196
196
  <div class="method-heading">
197
- <a href="HttpServer.src/M000062.html" target="Code" class="method-signature"
198
- onclick="popupCode('HttpServer.src/M000062.html');return false;">
197
+ <a href="HttpServer.src/M000063.html" target="Code" class="method-signature"
198
+ onclick="popupCode('HttpServer.src/M000063.html');return false;">
199
199
  <span class="method-name">new</span><span class="method-args">(host, port, num_processors=(2**30-1), timeout=0)</span>
200
200
  </a>
201
201
  </div>
@@ -230,12 +230,12 @@ cause problems on FBSD.
230
230
 
231
231
  <h3 class="section-bar">Public Instance methods</h3>
232
232
 
233
- <div id="method-M000063" class="method-detail">
234
- <a name="M000063"></a>
233
+ <div id="method-M000064" class="method-detail">
234
+ <a name="M000064"></a>
235
235
 
236
236
  <div class="method-heading">
237
- <a href="HttpServer.src/M000063.html" target="Code" class="method-signature"
238
- onclick="popupCode('HttpServer.src/M000063.html');return false;">
237
+ <a href="HttpServer.src/M000064.html" target="Code" class="method-signature"
238
+ onclick="popupCode('HttpServer.src/M000064.html');return false;">
239
239
  <span class="method-name">process_client</span><span class="method-args">(client)</span>
240
240
  </a>
241
241
  </div>
@@ -252,12 +252,12 @@ make it faster is more than welcome to take a crack at it.
252
252
  </div>
253
253
  </div>
254
254
 
255
- <div id="method-M000064" class="method-detail">
256
- <a name="M000064"></a>
255
+ <div id="method-M000065" class="method-detail">
256
+ <a name="M000065"></a>
257
257
 
258
258
  <div class="method-heading">
259
- <a href="HttpServer.src/M000064.html" target="Code" class="method-signature"
260
- onclick="popupCode('HttpServer.src/M000064.html');return false;">
259
+ <a href="HttpServer.src/M000065.html" target="Code" class="method-signature"
260
+ onclick="popupCode('HttpServer.src/M000065.html');return false;">
261
261
  <span class="method-name">reap_dead_workers</span><span class="method-args">(worker_list)</span>
262
262
  </a>
263
263
  </div>
@@ -271,12 +271,12 @@ servicing.
271
271
  </div>
272
272
  </div>
273
273
 
274
- <div id="method-M000066" class="method-detail">
275
- <a name="M000066"></a>
274
+ <div id="method-M000067" class="method-detail">
275
+ <a name="M000067"></a>
276
276
 
277
277
  <div class="method-heading">
278
- <a href="HttpServer.src/M000066.html" target="Code" class="method-signature"
279
- onclick="popupCode('HttpServer.src/M000066.html');return false;">
278
+ <a href="HttpServer.src/M000067.html" target="Code" class="method-signature"
279
+ onclick="popupCode('HttpServer.src/M000067.html');return false;">
280
280
  <span class="method-name">register</span><span class="method-args">(uri, handler, in_front=false)</span>
281
281
  </a>
282
282
  </div>
@@ -287,7 +287,7 @@ Simply registers a handler with the internal <a
287
287
  href="URIClassifier.html">URIClassifier</a>. When the URI is found in the
288
288
  prefix of a request then your handler&#8217;s HttpHandler::process method
289
289
  is called. See <a
290
- href="URIClassifier.html#M000091">Mongrel::URIClassifier#register</a> for
290
+ href="URIClassifier.html#M000093">Mongrel::URIClassifier#register</a> for
291
291
  more information.
292
292
  </p>
293
293
  <p>
@@ -297,12 +297,12 @@ the list. Otherwise it&#8217;s placed at the end of the list.
297
297
  </div>
298
298
  </div>
299
299
 
300
- <div id="method-M000065" class="method-detail">
301
- <a name="M000065"></a>
300
+ <div id="method-M000066" class="method-detail">
301
+ <a name="M000066"></a>
302
302
 
303
303
  <div class="method-heading">
304
- <a href="HttpServer.src/M000065.html" target="Code" class="method-signature"
305
- onclick="popupCode('HttpServer.src/M000065.html');return false;">
304
+ <a href="HttpServer.src/M000066.html" target="Code" class="method-signature"
305
+ onclick="popupCode('HttpServer.src/M000066.html');return false;">
306
306
  <span class="method-name">run</span><span class="method-args">()</span>
307
307
  </a>
308
308
  </div>
@@ -316,12 +316,12 @@ later.
316
316
  </div>
317
317
  </div>
318
318
 
319
- <div id="method-M000068" class="method-detail">
320
- <a name="M000068"></a>
319
+ <div id="method-M000069" class="method-detail">
320
+ <a name="M000069"></a>
321
321
 
322
322
  <div class="method-heading">
323
- <a href="HttpServer.src/M000068.html" target="Code" class="method-signature"
324
- onclick="popupCode('HttpServer.src/M000068.html');return false;">
323
+ <a href="HttpServer.src/M000069.html" target="Code" class="method-signature"
324
+ onclick="popupCode('HttpServer.src/M000069.html');return false;">
325
325
  <span class="method-name">stop</span><span class="method-args">()</span>
326
326
  </a>
327
327
  </div>
@@ -334,12 +334,12 @@ the request queue before finally exiting.
334
334
  </div>
335
335
  </div>
336
336
 
337
- <div id="method-M000067" class="method-detail">
338
- <a name="M000067"></a>
337
+ <div id="method-M000068" class="method-detail">
338
+ <a name="M000068"></a>
339
339
 
340
340
  <div class="method-heading">
341
- <a href="HttpServer.src/M000067.html" target="Code" class="method-signature"
342
- onclick="popupCode('HttpServer.src/M000067.html');return false;">
341
+ <a href="HttpServer.src/M000068.html" target="Code" class="method-signature"
342
+ onclick="popupCode('HttpServer.src/M000068.html');return false;">
343
343
  <span class="method-name">unregister</span><span class="method-args">(uri)</span>
344
344
  </a>
345
345
  </div>
@@ -347,7 +347,7 @@ the request queue before finally exiting.
347
347
  <div class="method-description">
348
348
  <p>
349
349
  Removes any handlers registered at the given URI. See <a
350
- href="URIClassifier.html#M000092">Mongrel::URIClassifier#unregister</a> for
350
+ href="URIClassifier.html#M000094">Mongrel::URIClassifier#unregister</a> for
351
351
  more information. Remember this removes them <b>all</b> so the entire
352
352
  processing chain goes away.
353
353
  </p>
@@ -5,79 +5,21 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>process_client (Mongrel::HttpServer)</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 515</span>
14
- 515: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
15
- 516: <span class="ruby-keyword kw">begin</span>
16
- 517: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
17
- 518: <span class="ruby-identifier">params</span> = {}
18
- 519:
19
- 520: <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
- 521: <span class="ruby-identifier">nparsed</span> = <span class="ruby-value">0</span>
21
- 522:
22
- 523: <span class="ruby-comment cmt"># Assumption: nparsed will always be less since data will get filled with more</span>
23
- 524: <span class="ruby-comment cmt"># after each parsing. If it doesn't get more then there was a problem</span>
24
- 525: <span class="ruby-comment cmt"># with the read operation on the client socket. Effect is to stop processing when the</span>
25
- 526: <span class="ruby-comment cmt"># socket can't fill the buffer for further parsing.</span>
26
- 527: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">nparsed</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>
27
- 528: <span class="ruby-identifier">nparsed</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>, <span class="ruby-identifier">nparsed</span>)
28
- 529:
29
- 530: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
30
- 531: <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>])
31
- 532:
32
- 533: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handlers</span>
33
- 534: <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>
34
- 535: <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>
35
- 536: <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>
36
- 537:
37
- 538: <span class="ruby-comment cmt"># TODO: Find a faster/better way to carve out the range, preferably without copying.</span>
38
- 539: <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">nparsed</span> <span class="ruby-operator">...</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">client</span>)
39
- 540:
40
- 541: <span class="ruby-comment cmt"># in the case of large file uploads the user could close the socket, so skip those requests</span>
41
- 542: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># nil signals from HttpRequest::initialize that the request was aborted</span>
42
- 543:
43
- 544: <span class="ruby-comment cmt"># request is good so far, continue processing the response</span>
44
- 545: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>)
45
- 546:
46
- 547: <span class="ruby-comment cmt"># Process each handler in registered order until we run out or one finalizes the response.</span>
47
- 548: <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>
48
- 549: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
49
- 550: <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> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
50
- 551: <span class="ruby-keyword kw">end</span>
51
- 552:
52
- 553: <span class="ruby-comment cmt"># And finally, if nobody closed the response off, we finalize it.</span>
53
- 554: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
54
- 555: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">finished</span>
55
- 556: <span class="ruby-keyword kw">end</span>
56
- 557: <span class="ruby-keyword kw">else</span>
57
- 558: <span class="ruby-comment cmt"># Didn't find it, return a stock 404 response.</span>
58
- 559: <span class="ruby-comment cmt"># TODO: Implement customer 404 files (but really they should use a real web server).</span>
59
- 560: <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>)
60
- 561: <span class="ruby-keyword kw">end</span>
61
- 562:
62
- 563: <span class="ruby-keyword kw">break</span> <span class="ruby-comment cmt">#done</span>
63
- 564: <span class="ruby-keyword kw">else</span>
64
- 565: <span class="ruby-comment cmt"># Parser is not done, queue up more data to read and continue parsing</span>
65
- 566: <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>)
66
- 567: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MAX_HEADER</span>
67
- 568: <span class="ruby-identifier">raise</span> <span class="ruby-constant">HttpParserError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;HEADER is longer than allowed, aborting client early.&quot;</span>)
68
- 569: <span class="ruby-keyword kw">end</span>
69
- 570: <span class="ruby-keyword kw">end</span>
70
- 571: <span class="ruby-keyword kw">end</span>
71
- 572: <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>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EBADF</span>
72
- 573: <span class="ruby-comment cmt"># ignored</span>
73
- 574: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">HttpParserError</span>
74
- 575: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{Time.now}: BAD CLIENT (#{params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last}): #$!&quot;</span>
75
- 576: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
76
- 577: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{Time.now}: ERROR: #$!&quot;</span>
77
- 578: <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>)
78
- 579: <span class="ruby-keyword kw">ensure</span>
79
- 580: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
80
- 581: <span class="ruby-keyword kw">end</span>
81
- 582: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 499</span>
14
+ 499: <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
+ 500: <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
+ 501: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
17
+ 502: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
18
+ 503: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
19
+ 504: <span class="ruby-ivar">@workers</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
20
+ 505: <span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">timeout</span>
21
+ 506: <span class="ruby-ivar">@num_processors</span> = <span class="ruby-identifier">num_processors</span>
22
+ 507: <span class="ruby-ivar">@death_time</span> = <span class="ruby-value">60</span>
23
+ 508: <span class="ruby-keyword kw">end</span></pre>
82
24
  </body>
83
25
  </html>
@@ -5,22 +5,85 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>reap_dead_workers (Mongrel::HttpServer)</title>
8
+ <title>process_client (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 587</span>
14
- 587: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reap_dead_workers</span>(<span class="ruby-identifier">worker_list</span>)
15
- 588: <span class="ruby-identifier">mark</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
16
- 589: <span class="ruby-identifier">worker_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
17
- 590: <span class="ruby-identifier">w</span>[<span class="ruby-identifier">:started_on</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">w</span>[<span class="ruby-identifier">:started_on</span>]
18
- 591:
19
- 592: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mark</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">w</span>[<span class="ruby-identifier">:started_on</span>] <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@death_time</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@timeout</span>
20
- 593: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Thread #{w.inspect} is too old, killing.&quot;</span>
21
- 594: <span class="ruby-identifier">w</span>.<span class="ruby-identifier">raise</span>(<span class="ruby-constant">StopServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;Timed out thread.&quot;</span>))
22
- 595: <span class="ruby-keyword kw">end</span>
23
- 596: <span class="ruby-keyword kw">end</span>
24
- 597: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 516</span>
14
+ 516: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
15
+ 517: <span class="ruby-keyword kw">begin</span>
16
+ 518: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span>
17
+ 519: <span class="ruby-identifier">params</span> = {}
18
+ 520:
19
+ 521: <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
+ 522: <span class="ruby-identifier">nparsed</span> = <span class="ruby-value">0</span>
21
+ 523:
22
+ 524: <span class="ruby-comment cmt"># Assumption: nparsed will always be less since data will get filled with more</span>
23
+ 525: <span class="ruby-comment cmt"># after each parsing. If it doesn't get more then there was a problem</span>
24
+ 526: <span class="ruby-comment cmt"># with the read operation on the client socket. Effect is to stop processing when the</span>
25
+ 527: <span class="ruby-comment cmt"># socket can't fill the buffer for further parsing.</span>
26
+ 528: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">nparsed</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>
27
+ 529: <span class="ruby-identifier">nparsed</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>, <span class="ruby-identifier">nparsed</span>)
28
+ 530:
29
+ 531: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span>
30
+ 532: <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>])
31
+ 533:
32
+ 534: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handlers</span>
33
+ 535: <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>
34
+ 536: <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>
35
+ 537: <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>
36
+ 538: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">nparsed</span> <span class="ruby-operator">...</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>
37
+ 539:
38
+ 540: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handlers</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">request_notify</span>
39
+ 541: <span class="ruby-comment cmt"># this first handler wants to be notified when the process starts</span>
40
+ 542: <span class="ruby-identifier">handlers</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">request_begins</span>(<span class="ruby-identifier">params</span>)
41
+ 543: <span class="ruby-keyword kw">end</span>
42
+ 544:
43
+ 545: <span class="ruby-comment cmt"># TODO: Find a faster/better way to carve out the range, preferably without copying.</span>
44
+ 546: <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">client</span>)
45
+ 547:
46
+ 548: <span class="ruby-comment cmt"># in the case of large file uploads the user could close the socket, so skip those requests</span>
47
+ 549: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># nil signals from HttpRequest::initialize that the request was aborted</span>
48
+ 550:
49
+ 551: <span class="ruby-comment cmt"># request is good so far, continue processing the response</span>
50
+ 552: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>)
51
+ 553:
52
+ 554: <span class="ruby-comment cmt"># Process each handler in registered order until we run out or one finalizes the response.</span>
53
+ 555: <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>
54
+ 556: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
55
+ 557: <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> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
56
+ 558: <span class="ruby-keyword kw">end</span>
57
+ 559:
58
+ 560: <span class="ruby-comment cmt"># And finally, if nobody closed the response off, we finalize it.</span>
59
+ 561: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
60
+ 562: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">finished</span>
61
+ 563: <span class="ruby-keyword kw">end</span>
62
+ 564: <span class="ruby-keyword kw">else</span>
63
+ 565: <span class="ruby-comment cmt"># Didn't find it, return a stock 404 response.</span>
64
+ 566: <span class="ruby-comment cmt"># TODO: Implement customer 404 files (but really they should use a real web server).</span>
65
+ 567: <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>)
66
+ 568: <span class="ruby-keyword kw">end</span>
67
+ 569:
68
+ 570: <span class="ruby-keyword kw">break</span> <span class="ruby-comment cmt">#done</span>
69
+ 571: <span class="ruby-keyword kw">else</span>
70
+ 572: <span class="ruby-comment cmt"># Parser is not done, queue up more data to read and continue parsing</span>
71
+ 573: <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>)
72
+ 574: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MAX_HEADER</span>
73
+ 575: <span class="ruby-identifier">raise</span> <span class="ruby-constant">HttpParserError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;HEADER is longer than allowed, aborting client early.&quot;</span>)
74
+ 576: <span class="ruby-keyword kw">end</span>
75
+ 577: <span class="ruby-keyword kw">end</span>
76
+ 578: <span class="ruby-keyword kw">end</span>
77
+ 579: <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>,<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EBADF</span>
78
+ 580: <span class="ruby-comment cmt"># ignored</span>
79
+ 581: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">HttpParserError</span>
80
+ 582: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{Time.now}: BAD CLIENT (#{params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last}): #$!&quot;</span>
81
+ 583: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
82
+ 584: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{Time.now}: ERROR: #$!&quot;</span>
83
+ 585: <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>)
84
+ 586: <span class="ruby-keyword kw">ensure</span>
85
+ 587: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span>
86
+ 588: <span class="ruby-keyword kw">end</span>
87
+ 589: <span class="ruby-keyword kw">end</span></pre>
25
88
  </body>
26
89
  </html>