mongrel 0.3.13.1 → 0.3.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. data/Rakefile +3 -1
  2. data/doc/rdoc/classes/Mongrel.html +3 -2
  3. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +49 -49
  4. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000101.html +11 -14
  5. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000102.html +34 -12
  6. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000103.html +21 -5
  7. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000104.html +14 -5
  8. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000105.html +12 -5
  9. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000106.html +5 -6
  10. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000107.html +18 -0
  11. data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000090.html → CGIWrapper.src/M000108.html} +5 -5
  12. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000109.html +19 -0
  13. data/doc/rdoc/classes/Mongrel/Camping.html +5 -5
  14. data/doc/rdoc/classes/Mongrel/Camping.src/{M000047.html → M000048.html} +0 -0
  15. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +10 -10
  16. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000049.html +5 -38
  17. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000050.html +51 -0
  18. data/doc/rdoc/classes/Mongrel/Command/Base.html +65 -65
  19. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +11 -29
  20. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +29 -5
  21. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +5 -5
  22. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +5 -5
  23. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +5 -5
  24. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +5 -9
  25. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +9 -5
  26. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +5 -5
  27. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +5 -5
  28. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +5 -11
  29. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +11 -11
  30. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +11 -5
  31. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000038.html +18 -0
  32. data/doc/rdoc/classes/Mongrel/Command/Registry.html +15 -15
  33. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +7 -12
  34. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000040.html +12 -37
  35. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000041.html +50 -0
  36. data/doc/rdoc/classes/Mongrel/Configurator.html +120 -114
  37. data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +14 -7
  38. data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +18 -10
  39. data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +7 -5
  40. data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +7 -21
  41. data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +10 -6
  42. data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +5 -17
  43. data/doc/rdoc/classes/Mongrel/Configurator.src/M000116.html +25 -20
  44. data/doc/rdoc/classes/Mongrel/Configurator.src/M000117.html +6 -5
  45. data/doc/rdoc/classes/Mongrel/Configurator.src/M000118.html +17 -11
  46. data/doc/rdoc/classes/Mongrel/Configurator.src/M000119.html +20 -6
  47. data/doc/rdoc/classes/Mongrel/Configurator.src/M000120.html +5 -5
  48. data/doc/rdoc/classes/Mongrel/Configurator.src/M000121.html +11 -9
  49. data/doc/rdoc/classes/Mongrel/Configurator.src/M000122.html +6 -12
  50. data/doc/rdoc/classes/Mongrel/Configurator.src/M000123.html +5 -5
  51. data/doc/rdoc/classes/Mongrel/Configurator.src/M000124.html +9 -22
  52. data/doc/rdoc/classes/Mongrel/Configurator.src/M000125.html +12 -5
  53. data/doc/rdoc/classes/Mongrel/Configurator.src/M000126.html +5 -20
  54. data/doc/rdoc/classes/Mongrel/Configurator.src/M000127.html +22 -5
  55. data/doc/rdoc/classes/Mongrel/Configurator.src/M000128.html +18 -0
  56. data/doc/rdoc/classes/Mongrel/Configurator.src/M000129.html +33 -0
  57. data/doc/rdoc/classes/Mongrel/Configurator.src/M000130.html +18 -0
  58. data/doc/rdoc/classes/Mongrel/Const.html +1 -1
  59. data/doc/rdoc/classes/Mongrel/DeflateFilter.html +10 -10
  60. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000096.html → M000099.html} +5 -5
  61. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000097.html → M000100.html} +14 -14
  62. data/doc/rdoc/classes/Mongrel/DirHandler.html +31 -31
  63. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +8 -30
  64. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +30 -29
  65. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +29 -50
  66. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +50 -26
  67. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +26 -5
  68. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000063.html +18 -0
  69. data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
  70. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000128.html → M000131.html} +4 -4
  71. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000129.html → M000132.html} +4 -4
  72. data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
  73. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000070.html → M000072.html} +4 -4
  74. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000071.html → M000073.html} +4 -4
  75. data/doc/rdoc/classes/Mongrel/HttpHandler.html +31 -10
  76. data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000076.html → M000078.html} +0 -0
  77. data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000079.html +17 -0
  78. data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000077.html → M000080.html} +3 -3
  79. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +25 -10
  80. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000022.html +3 -3
  81. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000023.html +4 -6
  82. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000024.html +6 -4
  83. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000025.html +17 -0
  84. data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
  85. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +5 -6
  86. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +7 -7
  87. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +7 -37
  88. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +37 -5
  89. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +5 -5
  90. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000056.html +5 -6
  91. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000050.html → M000057.html} +6 -6
  92. data/doc/rdoc/classes/Mongrel/HttpRequest.html +30 -21
  93. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000138.html +43 -19
  94. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000136.html → M000139.html} +6 -6
  95. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000137.html → M000140.html} +6 -6
  96. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000141.html +32 -0
  97. data/doc/rdoc/classes/Mongrel/HttpResponse.html +61 -61
  98. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +12 -9
  99. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +7 -9
  100. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +12 -9
  101. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +9 -18
  102. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000085.html +9 -8
  103. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +9 -7
  104. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000087.html +18 -7
  105. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000088.html +8 -7
  106. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000089.html +7 -5
  107. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000090.html +20 -0
  108. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000091.html +20 -0
  109. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000092.html +18 -0
  110. data/doc/rdoc/classes/Mongrel/HttpServer.html +63 -41
  111. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +12 -76
  112. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +74 -13
  113. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +18 -50
  114. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +8 -21
  115. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +38 -5
  116. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +21 -9
  117. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +18 -0
  118. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +22 -0
  119. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +15 -15
  120. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +26 -12
  121. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000043.html +12 -13
  122. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000044.html +26 -0
  123. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +15 -15
  124. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +9 -38
  125. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +38 -10
  126. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000047.html +23 -0
  127. data/doc/rdoc/classes/Mongrel/RedirectHandler.html +10 -10
  128. data/doc/rdoc/classes/Mongrel/RedirectHandler.src/{M000133.html → M000136.html} +8 -8
  129. data/doc/rdoc/classes/Mongrel/RedirectHandler.src/{M000134.html → M000137.html} +13 -13
  130. data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +16 -16
  131. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000130.html → M000133.html} +10 -10
  132. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000131.html → M000134.html} +10 -10
  133. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000132.html → M000135.html} +4 -4
  134. data/doc/rdoc/classes/Mongrel/StatusHandler.html +20 -20
  135. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000074.html +5 -29
  136. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000075.html +11 -7
  137. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000076.html +42 -0
  138. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000077.html +20 -0
  139. data/doc/rdoc/classes/Mongrel/TimeoutError.html +117 -0
  140. data/doc/rdoc/classes/Mongrel/URIClassifier.html +30 -30
  141. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000093.html +5 -38
  142. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000094.html +5 -23
  143. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000095.html +16 -60
  144. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000096.html +51 -0
  145. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000097.html +36 -0
  146. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000098.html +83 -0
  147. data/doc/rdoc/classes/RequestLog/Access.html +5 -5
  148. data/doc/rdoc/classes/RequestLog/Access.src/{M000139.html → M000142.html} +0 -0
  149. data/doc/rdoc/classes/RequestLog/Files.html +5 -5
  150. data/doc/rdoc/classes/RequestLog/Files.src/{M000140.html → M000143.html} +0 -0
  151. data/doc/rdoc/classes/RequestLog/Objects.html +5 -5
  152. data/doc/rdoc/classes/RequestLog/Objects.src/{M000142.html → M000145.html} +0 -0
  153. data/doc/rdoc/classes/RequestLog/Params.html +5 -5
  154. data/doc/rdoc/classes/RequestLog/Params.src/{M000143.html → M000146.html} +0 -0
  155. data/doc/rdoc/classes/RequestLog/Threads.html +5 -5
  156. data/doc/rdoc/classes/RequestLog/Threads.src/{M000141.html → M000144.html} +0 -0
  157. data/doc/rdoc/created.rid +1 -1
  158. data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
  159. data/doc/rdoc/files/lib/mongrel/camping_rb.html +2 -2
  160. data/doc/rdoc/files/lib/mongrel/cgi_rb.html +2 -2
  161. data/doc/rdoc/files/lib/mongrel/command_rb.html +2 -2
  162. data/doc/rdoc/files/lib/mongrel/debug_rb.html +2 -2
  163. data/doc/rdoc/files/lib/mongrel/handlers_rb.html +1 -1
  164. data/doc/rdoc/files/lib/mongrel/init_rb.html +2 -2
  165. data/doc/rdoc/files/lib/mongrel/rails_rb.html +2 -2
  166. data/doc/rdoc/files/lib/mongrel/stats_rb.html +2 -2
  167. data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +2 -2
  168. data/doc/rdoc/files/lib/mongrel_rb.html +2 -2
  169. data/doc/rdoc/fr_class_index.html +1 -0
  170. data/doc/rdoc/fr_method_index.html +125 -122
  171. data/ext/http11/http11.c +2 -2
  172. data/ext/http11/http11_parser.c +1 -1
  173. data/ext/http11/http11_parser.h +1 -1
  174. data/lib/mongrel.rb +70 -53
  175. data/lib/mongrel/camping.rb +1 -1
  176. data/lib/mongrel/cgi.rb +1 -1
  177. data/lib/mongrel/command.rb +1 -1
  178. data/lib/mongrel/debug.rb +1 -1
  179. data/lib/mongrel/handlers.rb +10 -1
  180. data/lib/mongrel/init.rb +1 -1
  181. data/lib/mongrel/rails.rb +1 -1
  182. data/lib/mongrel/stats.rb +1 -1
  183. data/lib/mongrel/tcphack.rb +1 -1
  184. data/test/test_command.rb +1 -1
  185. data/test/test_conditional.rb +1 -1
  186. data/test/test_configurator.rb +1 -1
  187. data/test/test_debug.rb +1 -1
  188. data/test/test_handlers.rb +1 -1
  189. data/test/test_http11.rb +1 -1
  190. data/test/test_response.rb +1 -1
  191. data/test/test_stats.rb +1 -1
  192. data/test/test_uriclassifier.rb +1 -1
  193. data/test/test_ws.rb +1 -1
  194. data/tools/trickletest.rb +28 -20
  195. metadata +50 -46
  196. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +0 -24
  197. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000099.html +0 -47
  198. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000100.html +0 -34
  199. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000048.html +0 -18
  200. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +0 -24
  201. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000038.html +0 -20
  202. data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +0 -29
  203. data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +0 -31
  204. data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +0 -20
  205. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000057.html +0 -21
  206. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000135.html +0 -52
  207. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +0 -25
  208. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +0 -20
  209. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +0 -25
  210. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +0 -25
  211. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000041.html +0 -39
  212. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000044.html +0 -22
  213. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000072.html +0 -18
  214. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000073.html +0 -24
  215. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000091.html +0 -18
  216. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +0 -39
@@ -5,38 +5,39 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>send_dir_listing (Mongrel::DirHandler)</title>
8
+ <title>can_serve (Mongrel::DirHandler)</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/handlers.rb, line 168</span>
14
- 168: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">response</span>)
15
- 169: <span class="ruby-comment cmt"># take off any trailing / so the links come out right</span>
16
- 170: <span class="ruby-identifier">base</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">base</span>)
17
- 171: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">chop!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>[<span class="ruby-value">-1</span>]
18
- 172:
19
- 173: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
20
- 174: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">200</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
21
- 175: <span class="ruby-identifier">head</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_TYPE</span>] = <span class="ruby-value str">&quot;text/html&quot;</span>
22
- 176: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Directory Listing&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;</span>
23
- 177: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">dir</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
24
- 178: <span class="ruby-identifier">child</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">child</span>)
25
- 179: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span>
26
- 180:
27
- 181: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span>
28
- 182: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}\&quot;&gt;Up to parent..&lt;/a&gt;&lt;br/&gt;&quot;</span>
29
- 183: <span class="ruby-keyword kw">else</span>
30
- 184: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}/\&quot;&gt;#{child}&lt;/a&gt;&lt;br/&gt;&quot;</span>
31
- 185: <span class="ruby-keyword kw">end</span>
32
- 186: <span class="ruby-keyword kw">end</span>
33
- 187: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span>
34
- 188: <span class="ruby-keyword kw">end</span>
35
- 189: <span class="ruby-keyword kw">else</span>
36
- 190: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
37
- 191: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;Directory listings not allowed&quot;</span>)
38
- 192: <span class="ruby-keyword kw">end</span>
39
- 193: <span class="ruby-keyword kw">end</span>
40
- 194: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 143</span>
14
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_serve</span>(<span class="ruby-identifier">path_info</span>)
15
+ 144: <span class="ruby-comment cmt"># TODO: investigate freezing the path_info to prevent double escaping</span>
16
+ 145: <span class="ruby-identifier">req_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">path_info</span>)), <span class="ruby-ivar">@path</span>)
17
+ 146:
18
+ 147: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req_path</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@path</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">req_path</span>
19
+ 148: <span class="ruby-comment cmt"># it exists and it's in the right location</span>
20
+ 149: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">req_path</span>
21
+ 150: <span class="ruby-comment cmt"># the request is for a directory</span>
22
+ 151: <span class="ruby-identifier">index</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-ivar">@index_html</span>)
23
+ 152: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">index</span>
24
+ 153: <span class="ruby-comment cmt"># serve the index</span>
25
+ 154: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">index</span>
26
+ 155: <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@listing_allowed</span>
27
+ 156: <span class="ruby-comment cmt"># serve the directory</span>
28
+ 157: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">req_path</span>
29
+ 158: <span class="ruby-keyword kw">else</span>
30
+ 159: <span class="ruby-comment cmt"># do not serve anything</span>
31
+ 160: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
32
+ 161: <span class="ruby-keyword kw">end</span>
33
+ 162: <span class="ruby-keyword kw">else</span>
34
+ 163: <span class="ruby-comment cmt"># it's a file and it's there</span>
35
+ 164: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">req_path</span>
36
+ 165: <span class="ruby-keyword kw">end</span>
37
+ 166: <span class="ruby-keyword kw">else</span>
38
+ 167: <span class="ruby-comment cmt"># does not exist or isn't in the right spot</span>
39
+ 168: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
40
+ 169: <span class="ruby-keyword kw">end</span>
41
+ 170: <span class="ruby-keyword kw">end</span></pre>
41
42
  </body>
42
43
  </html>
@@ -5,59 +5,38 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>send_file (Mongrel::DirHandler)</title>
8
+ <title>send_dir_listing (Mongrel::DirHandler)</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/handlers.rb, line 199</span>
14
- 199: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-identifier">header_only</span>=<span class="ruby-keyword kw">false</span>)
15
- 200:
16
- 201: <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">req_path</span>)
17
- 202:
18
- 203: <span class="ruby-comment cmt"># Set the last modified times as well and etag for all files</span>
19
- 204: <span class="ruby-identifier">mtime</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">mtime</span>
20
- 205: <span class="ruby-comment cmt"># Calculated the same as apache, not sure how well the works on win32</span>
21
- 206: <span class="ruby-identifier">etag</span> = <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETAG_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">ino</span>]
22
- 207:
23
- 208: <span class="ruby-identifier">unmodified_since</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_IF_UNMODIFIED_SINCE</span>]
24
- 209: <span class="ruby-identifier">none_match</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_IF_NONE_MATCH</span>]
25
- 210:
26
- 211: <span class="ruby-comment cmt"># test to see if this is a conditional request, and test if</span>
27
- 212: <span class="ruby-comment cmt"># the response would be identical to the last response</span>
28
- 213: <span class="ruby-identifier">same_response</span> = <span class="ruby-keyword kw">case</span>
29
- 214: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">last_response_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-identifier">unmodified_since</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
30
- 215: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">last_response_time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
31
- 216: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">mtime</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_response_time</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
32
- 217: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'*'</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
33
- 218: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">none_match</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/\s*,\s*/</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">etag</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
34
- 219: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">none_match</span> <span class="ruby-comment cmt"># validation successful if we get this far and at least one of the header exists</span>
35
- 220: <span class="ruby-keyword kw">end</span>
36
- 221:
37
- 222: <span class="ruby-identifier">header</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>
38
- 223: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETAG</span>] = <span class="ruby-identifier">etag</span>
39
- 224:
40
- 225: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">same_response</span>
41
- 226: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">304</span>) {}
42
- 227: <span class="ruby-keyword kw">else</span>
43
- 228: <span class="ruby-comment cmt"># first we setup the headers and status then we do a very fast send on the socket directly</span>
44
- 229: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-value">200</span>
45
- 230: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LAST_MODIFIED</span>] = <span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">httpdate</span>
46
- 231:
47
- 232: <span class="ruby-comment cmt"># set the mime type from our map based on the ending</span>
48
- 233: <span class="ruby-identifier">dot_at</span> = <span class="ruby-identifier">req_path</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value str">'.'</span>)
49
- 234: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dot_at</span>
50
- 235: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_TYPE</span>] = <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">req_path</span>[<span class="ruby-identifier">dot_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>]] <span class="ruby-operator">||</span> <span class="ruby-ivar">@default_content_type</span>
51
- 236: <span class="ruby-keyword kw">end</span>
52
- 237:
53
- 238: <span class="ruby-comment cmt"># send a status with out content length</span>
54
- 239: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_status</span>(<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>)
55
- 240: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_header</span>
56
- 241:
57
- 242: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">header_only</span>
58
- 243: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>)
59
- 244: <span class="ruby-keyword kw">end</span>
60
- 245: <span class="ruby-keyword kw">end</span>
61
- 246: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 177</span>
14
+ 177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">response</span>)
15
+ 178: <span class="ruby-comment cmt"># take off any trailing / so the links come out right</span>
16
+ 179: <span class="ruby-identifier">base</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">base</span>)
17
+ 180: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">chop!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>[<span class="ruby-value">-1</span>]
18
+ 181:
19
+ 182: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
20
+ 183: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">200</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
21
+ 184: <span class="ruby-identifier">head</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_TYPE</span>] = <span class="ruby-value str">&quot;text/html&quot;</span>
22
+ 185: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Directory Listing&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;</span>
23
+ 186: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">dir</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
24
+ 187: <span class="ruby-identifier">child</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">child</span>)
25
+ 188: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span>
26
+ 189:
27
+ 190: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span>
28
+ 191: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}\&quot;&gt;Up to parent..&lt;/a&gt;&lt;br/&gt;&quot;</span>
29
+ 192: <span class="ruby-keyword kw">else</span>
30
+ 193: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}/\&quot;&gt;#{child}&lt;/a&gt;&lt;br/&gt;&quot;</span>
31
+ 194: <span class="ruby-keyword kw">end</span>
32
+ 195: <span class="ruby-keyword kw">end</span>
33
+ 196: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span>
34
+ 197: <span class="ruby-keyword kw">end</span>
35
+ 198: <span class="ruby-keyword kw">else</span>
36
+ 199: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
37
+ 200: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;Directory listings not allowed&quot;</span>)
38
+ 201: <span class="ruby-keyword kw">end</span>
39
+ 202: <span class="ruby-keyword kw">end</span>
40
+ 203: <span class="ruby-keyword kw">end</span></pre>
62
41
  </body>
63
42
  </html>
@@ -5,35 +5,59 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>process (Mongrel::DirHandler)</title>
8
+ <title>send_file (Mongrel::DirHandler)</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/handlers.rb, line 250</span>
14
- 250: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
- 251: <span class="ruby-identifier">req_method</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">REQUEST_METHOD</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GET</span>
16
- 252: <span class="ruby-identifier">req_path</span> = <span class="ruby-identifier">can_serve</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_INFO</span>]
17
- 253: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">req_path</span>
18
- 254: <span class="ruby-comment cmt"># not found, return a 404</span>
19
- 255: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">404</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
20
- 256: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;File not found&quot;</span>
21
- 257: <span class="ruby-keyword kw">end</span>
22
- 258: <span class="ruby-keyword kw">else</span>
23
- 259: <span class="ruby-keyword kw">begin</span>
24
- 260: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">req_path</span>
25
- 261: <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">request</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>], <span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">response</span>)
26
- 262: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">req_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HEAD</span>
27
- 263: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-keyword kw">true</span>)
28
- 264: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">req_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GET</span>
29
- 265: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-keyword kw">false</span>)
30
- 266: <span class="ruby-keyword kw">else</span>
31
- 267: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">ONLY_HEAD_GET</span>) }
32
- 268: <span class="ruby-keyword kw">end</span>
33
- 269: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
34
- 270: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Error sending file #{req_path}: #{details}&quot;</span>
35
- 271: <span class="ruby-keyword kw">end</span>
36
- 272: <span class="ruby-keyword kw">end</span>
37
- 273: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 208</span>
14
+ 208: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-identifier">header_only</span>=<span class="ruby-keyword kw">false</span>)
15
+ 209:
16
+ 210: <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">req_path</span>)
17
+ 211:
18
+ 212: <span class="ruby-comment cmt"># Set the last modified times as well and etag for all files</span>
19
+ 213: <span class="ruby-identifier">mtime</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">mtime</span>
20
+ 214: <span class="ruby-comment cmt"># Calculated the same as apache, not sure how well the works on win32</span>
21
+ 215: <span class="ruby-identifier">etag</span> = <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETAG_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">ino</span>]
22
+ 216:
23
+ 217: <span class="ruby-identifier">unmodified_since</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_IF_UNMODIFIED_SINCE</span>]
24
+ 218: <span class="ruby-identifier">none_match</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_IF_NONE_MATCH</span>]
25
+ 219:
26
+ 220: <span class="ruby-comment cmt"># test to see if this is a conditional request, and test if</span>
27
+ 221: <span class="ruby-comment cmt"># the response would be identical to the last response</span>
28
+ 222: <span class="ruby-identifier">same_response</span> = <span class="ruby-keyword kw">case</span>
29
+ 223: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">last_response_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-identifier">unmodified_since</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
30
+ 224: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">last_response_time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
31
+ 225: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">mtime</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_response_time</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
32
+ 226: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'*'</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
33
+ 227: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">none_match</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">none_match</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/\s*,\s*/</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">etag</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
34
+ 228: <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">unmodified_since</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">none_match</span> <span class="ruby-comment cmt"># validation successful if we get this far and at least one of the header exists</span>
35
+ 229: <span class="ruby-keyword kw">end</span>
36
+ 230:
37
+ 231: <span class="ruby-identifier">header</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>
38
+ 232: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ETAG</span>] = <span class="ruby-identifier">etag</span>
39
+ 233:
40
+ 234: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">same_response</span>
41
+ 235: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">304</span>) {}
42
+ 236: <span class="ruby-keyword kw">else</span>
43
+ 237: <span class="ruby-comment cmt"># first we setup the headers and status then we do a very fast send on the socket directly</span>
44
+ 238: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-value">200</span>
45
+ 239: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LAST_MODIFIED</span>] = <span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">httpdate</span>
46
+ 240:
47
+ 241: <span class="ruby-comment cmt"># set the mime type from our map based on the ending</span>
48
+ 242: <span class="ruby-identifier">dot_at</span> = <span class="ruby-identifier">req_path</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value str">'.'</span>)
49
+ 243: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dot_at</span>
50
+ 244: <span class="ruby-identifier">header</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_TYPE</span>] = <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">req_path</span>[<span class="ruby-identifier">dot_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>]] <span class="ruby-operator">||</span> <span class="ruby-ivar">@default_content_type</span>
51
+ 245: <span class="ruby-keyword kw">end</span>
52
+ 246:
53
+ 247: <span class="ruby-comment cmt"># send a status with out content length</span>
54
+ 248: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_status</span>(<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>)
55
+ 249: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_header</span>
56
+ 250:
57
+ 251: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">header_only</span>
58
+ 252: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>)
59
+ 253: <span class="ruby-keyword kw">end</span>
60
+ 254: <span class="ruby-keyword kw">end</span>
61
+ 255: <span class="ruby-keyword kw">end</span></pre>
38
62
  </body>
39
63
  </html>
@@ -5,14 +5,35 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>add_mime_type (Mongrel::DirHandler)</title>
8
+ <title>process (Mongrel::DirHandler)</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/handlers.rb, line 277</span>
14
- 277: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">DirHandler</span><span class="ruby-operator">::</span><span class="ruby-identifier">add_mime_type</span>(<span class="ruby-identifier">extension</span>, <span class="ruby-identifier">type</span>)
15
- 278: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">extension</span>] = <span class="ruby-identifier">type</span>
16
- 279: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 259</span>
14
+ 259: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
+ 260: <span class="ruby-identifier">req_method</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">REQUEST_METHOD</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GET</span>
16
+ 261: <span class="ruby-identifier">req_path</span> = <span class="ruby-identifier">can_serve</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_INFO</span>]
17
+ 262: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">req_path</span>
18
+ 263: <span class="ruby-comment cmt"># not found, return a 404</span>
19
+ 264: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">404</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
20
+ 265: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;File not found&quot;</span>
21
+ 266: <span class="ruby-keyword kw">end</span>
22
+ 267: <span class="ruby-keyword kw">else</span>
23
+ 268: <span class="ruby-keyword kw">begin</span>
24
+ 269: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">req_path</span>
25
+ 270: <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">request</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>], <span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">response</span>)
26
+ 271: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">req_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HEAD</span>
27
+ 272: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-keyword kw">true</span>)
28
+ 273: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">req_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">GET</span>
29
+ 274: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req_path</span>, <span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-keyword kw">false</span>)
30
+ 275: <span class="ruby-keyword kw">else</span>
31
+ 276: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">ONLY_HEAD_GET</span>) }
32
+ 277: <span class="ruby-keyword kw">end</span>
33
+ 278: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
34
+ 279: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Error sending file #{req_path}: #{details}&quot;</span>
35
+ 280: <span class="ruby-keyword kw">end</span>
36
+ 281: <span class="ruby-keyword kw">end</span>
37
+ 282: <span class="ruby-keyword kw">end</span></pre>
17
38
  </body>
18
39
  </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>add_mime_type (Mongrel::DirHandler)</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/handlers.rb, line 286</span>
14
+ 286: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">DirHandler</span><span class="ruby-operator">::</span><span class="ruby-identifier">add_mime_type</span>(<span class="ruby-identifier">extension</span>, <span class="ruby-identifier">type</span>)
15
+ 287: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">extension</span>] = <span class="ruby-identifier">type</span>
16
+ 288: <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -96,8 +96,8 @@ with a custom message for special URIs.
96
96
  <h3 class="section-bar">Methods</h3>
97
97
 
98
98
  <div class="name-list">
99
- <a href="#M000128">new</a>&nbsp;&nbsp;
100
- <a href="#M000129">process</a>&nbsp;&nbsp;
99
+ <a href="#M000131">new</a>&nbsp;&nbsp;
100
+ <a href="#M000132">process</a>&nbsp;&nbsp;
101
101
  </div>
102
102
  </div>
103
103
 
@@ -119,12 +119,12 @@ with a custom message for special URIs.
119
119
  <div id="methods">
120
120
  <h3 class="section-bar">Public Class methods</h3>
121
121
 
122
- <div id="method-M000128" class="method-detail">
123
- <a name="M000128"></a>
122
+ <div id="method-M000131" class="method-detail">
123
+ <a name="M000131"></a>
124
124
 
125
125
  <div class="method-heading">
126
- <a href="Error404Handler.src/M000128.html" target="Code" class="method-signature"
127
- onclick="popupCode('Error404Handler.src/M000128.html');return false;">
126
+ <a href="Error404Handler.src/M000131.html" target="Code" class="method-signature"
127
+ onclick="popupCode('Error404Handler.src/M000131.html');return false;">
128
128
  <span class="method-name">new</span><span class="method-args">(msg)</span>
129
129
  </a>
130
130
  </div>
@@ -139,12 +139,12 @@ it&#8217;s pretty efficient.
139
139
 
140
140
  <h3 class="section-bar">Public Instance methods</h3>
141
141
 
142
- <div id="method-M000129" class="method-detail">
143
- <a name="M000129"></a>
142
+ <div id="method-M000132" class="method-detail">
143
+ <a name="M000132"></a>
144
144
 
145
145
  <div class="method-heading">
146
- <a href="Error404Handler.src/M000129.html" target="Code" class="method-signature"
147
- onclick="popupCode('Error404Handler.src/M000129.html');return false;">
146
+ <a href="Error404Handler.src/M000132.html" target="Code" class="method-signature"
147
+ onclick="popupCode('Error404Handler.src/M000132.html');return false;">
148
148
  <span class="method-name">process</span><span class="method-args">(request, response)</span>
149
149
  </a>
150
150
  </div>
@@ -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/handlers.rb, line 80</span>
14
- 80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
- 81: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR_404_RESPONSE</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">msg</span>
16
- 82: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 89</span>
14
+ 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
+ 90: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR_404_RESPONSE</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">msg</span>
16
+ 91: <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/handlers.rb, line 85</span>
14
- 85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
- 86: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@response</span>)
16
- 87: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 94</span>
14
+ 94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
+ 95: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@response</span>)
16
+ 96: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -101,8 +101,8 @@ there.
101
101
  <h3 class="section-bar">Methods</h3>
102
102
 
103
103
  <div class="name-list">
104
- <a href="#M000071">[]=</a>&nbsp;&nbsp;
105
- <a href="#M000070">new</a>&nbsp;&nbsp;
104
+ <a href="#M000073">[]=</a>&nbsp;&nbsp;
105
+ <a href="#M000072">new</a>&nbsp;&nbsp;
106
106
  </div>
107
107
  </div>
108
108
 
@@ -137,12 +137,12 @@ there.
137
137
  <div id="methods">
138
138
  <h3 class="section-bar">Public Class methods</h3>
139
139
 
140
- <div id="method-M000070" class="method-detail">
141
- <a name="M000070"></a>
140
+ <div id="method-M000072" class="method-detail">
141
+ <a name="M000072"></a>
142
142
 
143
143
  <div class="method-heading">
144
- <a href="HeaderOut.src/M000070.html" target="Code" class="method-signature"
145
- onclick="popupCode('HeaderOut.src/M000070.html');return false;">
144
+ <a href="HeaderOut.src/M000072.html" target="Code" class="method-signature"
145
+ onclick="popupCode('HeaderOut.src/M000072.html');return false;">
146
146
  <span class="method-name">new</span><span class="method-args">(out)</span>
147
147
  </a>
148
148
  </div>
@@ -153,12 +153,12 @@ there.
153
153
 
154
154
  <h3 class="section-bar">Public Instance methods</h3>
155
155
 
156
- <div id="method-M000071" class="method-detail">
157
- <a name="M000071"></a>
156
+ <div id="method-M000073" class="method-detail">
157
+ <a name="M000073"></a>
158
158
 
159
159
  <div class="method-heading">
160
- <a href="HeaderOut.src/M000071.html" target="Code" class="method-signature"
161
- onclick="popupCode('HeaderOut.src/M000071.html');return false;">
160
+ <a href="HeaderOut.src/M000073.html" target="Code" class="method-signature"
161
+ onclick="popupCode('HeaderOut.src/M000073.html');return false;">
162
162
  <span class="method-name">[]=</span><span class="method-args">(key,value)</span>
163
163
  </a>
164
164
  </div>
@@ -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 284</span>
14
- 284: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
- 285: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
- 286: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 294</span>
14
+ 294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
+ 295: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
+ 296: <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 289</span>
14
- 289: <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
- 290: <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
- 291: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 299</span>
14
+ 299: <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
+ 300: <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
+ 301: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>