mongrel 0.3.12.4 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/Rakefile +44 -33
  2. data/bin/mongrel_rails +67 -34
  3. data/doc/rdoc/classes/IO.html +10 -10
  4. data/doc/rdoc/classes/IO.src/{M000005.html → M000001.html} +5 -5
  5. data/doc/rdoc/classes/IO.src/{M000006.html → M000002.html} +5 -5
  6. data/doc/rdoc/classes/Kernel.html +10 -10
  7. data/doc/rdoc/classes/Kernel.src/{M000025.html → M000020.html} +5 -5
  8. data/doc/rdoc/classes/Kernel.src/M000021.html +23 -0
  9. data/doc/rdoc/classes/Mongrel.html +25 -4
  10. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +383 -0
  11. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000096.html +11 -5
  12. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000097.html +34 -5
  13. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +21 -6
  14. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000093.html → M000099.html} +13 -13
  15. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000094.html → M000100.html} +11 -11
  16. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000095.html → M000101.html} +4 -4
  17. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000102.html +18 -0
  18. data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000084.html → CGIWrapper.src/M000103.html} +5 -5
  19. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000104.html +19 -0
  20. data/doc/rdoc/classes/Mongrel/Camping.html +5 -5
  21. data/doc/rdoc/classes/Mongrel/Camping.src/M000046.html +22 -0
  22. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +10 -10
  23. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/{M000049.html → M000047.html} +4 -4
  24. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000048.html +51 -0
  25. data/doc/rdoc/classes/Mongrel/Command.html +13 -0
  26. data/doc/rdoc/classes/Mongrel/Command/Base.html +95 -50
  27. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +24 -0
  28. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +42 -0
  29. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +18 -0
  30. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +18 -0
  31. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +18 -0
  32. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +5 -11
  33. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +9 -28
  34. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +5 -5
  35. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +5 -5
  36. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +5 -5
  37. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +11 -9
  38. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +11 -5
  39. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +5 -5
  40. data/doc/rdoc/classes/Mongrel/Command/Registry.html +15 -15
  41. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000037.html +20 -0
  42. data/doc/rdoc/classes/Mongrel/Command/Registry.src/{M000040.html → M000038.html} +11 -11
  43. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +37 -7
  44. data/doc/rdoc/classes/Mongrel/Configurator.html +651 -0
  45. data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +16 -20
  46. data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +18 -5
  47. data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +7 -11
  48. data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +7 -6
  49. data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +10 -9
  50. data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +5 -8
  51. data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +21 -5
  52. data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +6 -15
  53. data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +17 -5
  54. data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +20 -33
  55. data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +5 -5
  56. data/doc/rdoc/classes/Mongrel/Configurator.src/M000116.html +24 -0
  57. data/doc/rdoc/classes/Mongrel/Configurator.src/M000117.html +19 -0
  58. data/doc/rdoc/classes/Mongrel/Configurator.src/M000118.html +22 -0
  59. data/doc/rdoc/classes/Mongrel/Configurator.src/M000119.html +25 -0
  60. data/doc/rdoc/classes/Mongrel/Configurator.src/M000120.html +18 -0
  61. data/doc/rdoc/classes/Mongrel/Configurator.src/M000121.html +35 -0
  62. data/doc/rdoc/classes/Mongrel/Configurator.src/M000122.html +18 -0
  63. data/doc/rdoc/classes/Mongrel/Configurator.src/M000123.html +33 -0
  64. data/doc/rdoc/classes/Mongrel/Configurator.src/M000124.html +18 -0
  65. data/doc/rdoc/classes/Mongrel/Const.html +39 -7
  66. data/doc/rdoc/classes/Mongrel/DeflateFilter.html +181 -0
  67. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000094.html +19 -0
  68. data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000095.html +28 -0
  69. data/doc/rdoc/classes/Mongrel/DirHandler.html +48 -33
  70. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +21 -0
  71. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000057.html +43 -0
  72. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +29 -7
  73. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +50 -29
  74. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +26 -27
  75. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +5 -38
  76. data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
  77. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000116.html → M000125.html} +4 -4
  78. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000117.html → M000126.html} +4 -4
  79. data/doc/rdoc/classes/Mongrel/HeaderOut.html +185 -0
  80. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000072.html → M000069.html} +4 -4
  81. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000073.html → M000070.html} +4 -4
  82. data/doc/rdoc/classes/Mongrel/HttpHandler.html +170 -0
  83. data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000074.html → M000075.html} +3 -3
  84. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +20 -10
  85. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/{M000027.html → M000022.html} +5 -4
  86. data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/{M000028.html → M000023.html} +3 -3
  87. data/doc/rdoc/classes/Mongrel/HttpParser.html +41 -36
  88. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000056.html → M000049.html} +6 -5
  89. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000057.html → M000050.html} +7 -6
  90. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +7 -6
  91. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +37 -7
  92. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +5 -7
  93. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +6 -22
  94. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +6 -5
  95. data/doc/rdoc/classes/Mongrel/HttpRequest.html +239 -0
  96. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000130.html +52 -0
  97. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000119.html → M000131.html} +6 -6
  98. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000120.html → M000132.html} +6 -6
  99. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000121.html → M000133.html} +18 -18
  100. data/doc/rdoc/classes/Mongrel/HttpResponse.html +439 -0
  101. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +12 -7
  102. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +7 -12
  103. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +12 -9
  104. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +9 -9
  105. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +9 -10
  106. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +9 -5
  107. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +18 -7
  108. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +8 -5
  109. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +20 -0
  110. data/doc/rdoc/classes/Mongrel/{HttpServer.src/M000069.html → HttpResponse.src/M000085.html} +7 -5
  111. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +20 -0
  112. data/doc/rdoc/classes/Mongrel/{Configurator.src/M000101.html → HttpResponse.src/M000087.html} +5 -5
  113. data/doc/rdoc/classes/Mongrel/HttpServer.html +68 -59
  114. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +25 -0
  115. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +83 -0
  116. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +13 -11
  117. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +50 -53
  118. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +21 -11
  119. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +5 -47
  120. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +9 -15
  121. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +16 -16
  122. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000040.html +39 -0
  123. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/{M000043.html → M000041.html} +11 -11
  124. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +13 -22
  125. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +17 -17
  126. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000043.html +22 -0
  127. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000044.html +51 -0
  128. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +10 -9
  129. data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +211 -0
  130. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000127.html +24 -0
  131. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000128.html +24 -0
  132. data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000129.html +18 -0
  133. data/doc/rdoc/classes/{Class.html → Mongrel/StatusHandler.html} +42 -45
  134. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +18 -0
  135. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000072.html +24 -0
  136. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000073.html +42 -0
  137. data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000074.html +20 -0
  138. data/doc/rdoc/classes/Mongrel/StopServer.html +117 -0
  139. data/doc/rdoc/classes/Mongrel/URIClassifier.html +314 -0
  140. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000088.html +5 -23
  141. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html +5 -70
  142. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000086.html → M000090.html} +0 -0
  143. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000087.html → M000091.html} +0 -0
  144. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +36 -0
  145. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000093.html +83 -0
  146. data/doc/rdoc/classes/MongrelDbg.html +25 -25
  147. data/doc/rdoc/classes/MongrelDbg.src/{M000020.html → M000015.html} +5 -5
  148. data/doc/rdoc/classes/MongrelDbg.src/{M000021.html → M000016.html} +6 -6
  149. data/doc/rdoc/classes/MongrelDbg.src/{M000022.html → M000017.html} +8 -8
  150. data/doc/rdoc/classes/MongrelDbg.src/{M000023.html → M000018.html} +7 -7
  151. data/doc/rdoc/classes/MongrelDbg.src/{M000024.html → M000019.html} +4 -4
  152. data/doc/rdoc/classes/ObjectTracker.html +10 -40
  153. data/doc/rdoc/classes/ObjectTracker.src/M000013.html +27 -0
  154. data/doc/rdoc/classes/ObjectTracker.src/M000014.html +44 -0
  155. data/doc/rdoc/classes/RequestLog.html +115 -0
  156. data/doc/rdoc/classes/RequestLog/Access.html +151 -0
  157. data/doc/rdoc/classes/RequestLog/Access.src/{M000122.html → M000134.html} +5 -5
  158. data/doc/rdoc/classes/RequestLog/Files.html +144 -0
  159. data/doc/rdoc/classes/RequestLog/Files.src/{M000123.html → M000135.html} +5 -5
  160. data/doc/rdoc/classes/RequestLog/Objects.html +144 -0
  161. data/doc/rdoc/classes/RequestLog/Objects.src/{M000124.html → M000137.html} +5 -5
  162. data/doc/rdoc/classes/RequestLog/Params.html +144 -0
  163. data/doc/rdoc/classes/RequestLog/Params.src/{M000125.html → M000138.html} +5 -5
  164. data/doc/rdoc/classes/RequestLog/Threads.html +144 -0
  165. data/doc/rdoc/classes/RequestLog/Threads.src/M000136.html +34 -0
  166. data/doc/rdoc/classes/Stats.html +54 -36
  167. data/doc/rdoc/classes/Stats.src/{M000013.html → M000005.html} +6 -5
  168. data/doc/rdoc/classes/Stats.src/M000006.html +23 -0
  169. data/doc/rdoc/classes/Stats.src/M000007.html +26 -0
  170. data/doc/rdoc/classes/Stats.src/M000008.html +18 -0
  171. data/doc/rdoc/classes/Stats.src/M000009.html +5 -6
  172. data/doc/rdoc/classes/Stats.src/M000010.html +5 -10
  173. data/doc/rdoc/classes/Stats.src/M000011.html +10 -13
  174. data/doc/rdoc/classes/Stats.src/M000012.html +7 -5
  175. data/doc/rdoc/classes/TCPServer.html +9 -9
  176. data/doc/rdoc/classes/TCPServer.src/M000003.html +19 -0
  177. data/doc/rdoc/created.rid +1 -1
  178. data/doc/rdoc/files/COPYING.html +1 -1
  179. data/doc/rdoc/files/LICENSE.html +1 -1
  180. data/doc/rdoc/files/README.html +1 -1
  181. data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
  182. data/doc/rdoc/files/lib/mongrel/camping_rb.html +28 -1
  183. data/doc/rdoc/files/lib/mongrel/cgi_rb.html +28 -1
  184. data/doc/rdoc/files/lib/mongrel/command_rb.html +28 -1
  185. data/doc/rdoc/files/lib/mongrel/debug_rb.html +28 -1
  186. data/doc/rdoc/files/lib/mongrel/handlers_rb.html +3 -3
  187. data/doc/rdoc/files/lib/mongrel/init_rb.html +28 -1
  188. data/doc/rdoc/files/lib/mongrel/rails_rb.html +28 -1
  189. data/doc/rdoc/files/lib/mongrel/stats_rb.html +21 -10
  190. data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +23 -4
  191. data/doc/rdoc/files/lib/mongrel_rb.html +33 -1
  192. data/doc/rdoc/fr_class_index.html +65 -0
  193. data/doc/rdoc/fr_file_index.html +40 -0
  194. data/doc/rdoc/fr_method_index.html +164 -0
  195. data/doc/rdoc/index.html +24 -0
  196. data/examples/camping/blog.rb +1 -1
  197. data/examples/camping/tepee.rb +4 -3
  198. data/examples/simpletest.rb +15 -14
  199. data/ext/http11/http11.c +52 -18
  200. data/ext/http11/http11_parser.c +194 -177
  201. data/ext/http11/http11_parser.h +23 -5
  202. data/lib/mongrel.rb +295 -134
  203. data/lib/mongrel/camping.rb +48 -6
  204. data/lib/mongrel/cgi.rb +20 -2
  205. data/lib/mongrel/command.rb +76 -27
  206. data/lib/mongrel/debug.rb +42 -13
  207. data/lib/mongrel/handlers.rb +218 -59
  208. data/lib/mongrel/init.rb +18 -0
  209. data/lib/mongrel/rails.rb +61 -44
  210. data/lib/mongrel/stats.rb +30 -2
  211. data/lib/mongrel/tcphack.rb +18 -0
  212. data/setup.rb +799 -574
  213. data/test/mime.yaml +3 -0
  214. data/test/mongrel.conf +1 -0
  215. data/test/test_command.rb +101 -0
  216. data/test/test_conditional.rb +124 -0
  217. data/test/test_configurator.rb +56 -22
  218. data/test/test_debug.rb +18 -2
  219. data/test/test_handlers.rb +105 -0
  220. data/test/test_http11.rb +27 -9
  221. data/test/test_response.rb +38 -0
  222. data/test/test_stats.rb +21 -2
  223. data/test/test_uriclassifier.rb +18 -0
  224. data/test/test_ws.rb +105 -19
  225. data/test/testhelp.rb +36 -0
  226. data/tools/rakehelp.rb +52 -46
  227. data/tools/trickletest.rb +37 -0
  228. metadata +127 -76
  229. data/doc/rdoc/classes/Class.src/M000001.html +0 -24
  230. data/doc/rdoc/classes/Class.src/M000002.html +0 -62
  231. data/doc/rdoc/classes/Class.src/M000003.html +0 -21
  232. data/doc/rdoc/classes/Class.src/M000004.html +0 -20
  233. data/doc/rdoc/classes/Kernel.src/M000026.html +0 -25
  234. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000090.html +0 -24
  235. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000091.html +0 -47
  236. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000092.html +0 -34
  237. data/doc/rdoc/classes/Mongrel/Camping.src/M000048.html +0 -22
  238. data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000050.html +0 -27
  239. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +0 -18
  240. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000038.html +0 -18
  241. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000041.html +0 -46
  242. data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +0 -24
  243. data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +0 -23
  244. data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +0 -32
  245. data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +0 -19
  246. data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +0 -31
  247. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +0 -40
  248. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000063.html +0 -18
  249. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000118.html +0 -28
  250. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +0 -26
  251. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +0 -22
  252. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +0 -18
  253. data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000044.html +0 -32
  254. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +0 -48
  255. data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000047.html +0 -23
  256. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000085.html +0 -18
  257. data/doc/rdoc/classes/ObjectTracker.src/M000016.html +0 -22
  258. data/doc/rdoc/classes/ObjectTracker.src/M000017.html +0 -18
  259. data/doc/rdoc/classes/ObjectTracker.src/M000018.html +0 -18
  260. data/doc/rdoc/classes/ObjectTracker.src/M000019.html +0 -44
  261. data/doc/rdoc/classes/Stats.src/M000014.html +0 -19
  262. data/doc/rdoc/classes/Stats.src/M000015.html +0 -20
  263. data/doc/rdoc/classes/TCPServer.src/M000007.html +0 -19
  264. data/lib/mongrel/#rails.rb# +0 -178
@@ -1,3 +1,21 @@
1
+ # Mongrel Web Server - A Mostly Ruby Webserver and Library
2
+ #
3
+ # Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+
1
19
  require 'test/unit'
2
20
  require 'http11'
3
21
  require 'mongrel'
@@ -12,7 +30,7 @@ class HttpParserTest < Test::Unit::TestCase
12
30
  parser = HttpParser.new
13
31
  req = {}
14
32
  http = "GET / HTTP/1.1\r\n\r\n"
15
- nread = parser.execute(req, http);
33
+ nread = parser.execute(req, http, 0)
16
34
  assert nread == http.length, "Failed to parse the full HTTP request"
17
35
  assert parser.finished?, "Parser didn't finish"
18
36
  assert !parser.error?, "Parser had error"
@@ -29,7 +47,7 @@ class HttpParserTest < Test::Unit::TestCase
29
47
 
30
48
  error = false
31
49
  begin
32
- nread = parser.execute(req, bad_http)
50
+ nread = parser.execute(req, bad_http, 0)
33
51
  rescue => details
34
52
  error = true
35
53
  end
@@ -61,7 +79,7 @@ class HttpParserTest < Test::Unit::TestCase
61
79
  100.times do |c|
62
80
  get = "GET /#{rand_data(1024, 1024+(c*1024))} HTTP/1.1\r\n"
63
81
  assert_raises Mongrel::HttpParserError do
64
- parser.execute({}, get)
82
+ parser.execute({}, get, 0)
65
83
  parser.reset
66
84
  end
67
85
  end
@@ -70,7 +88,7 @@ class HttpParserTest < Test::Unit::TestCase
70
88
  100.times do |c|
71
89
  get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-#{rand_data(1024, 1024+(c*1024))}: Test\r\n\r\n"
72
90
  assert_raises Mongrel::HttpParserError do
73
- parser.execute({}, get)
91
+ parser.execute({}, get, 0)
74
92
  parser.reset
75
93
  end
76
94
  end
@@ -79,7 +97,7 @@ class HttpParserTest < Test::Unit::TestCase
79
97
  100.times do |c|
80
98
  get = "GET /#{rand_data(10,120)} HTTP/1.1\r\nX-Test: #{rand_data(1024, 1024+(c*1024), false)}\r\n\r\n"
81
99
  assert_raises Mongrel::HttpParserError do
82
- parser.execute({}, get)
100
+ parser.execute({}, get, 0)
83
101
  parser.reset
84
102
  end
85
103
  end
@@ -88,7 +106,7 @@ class HttpParserTest < Test::Unit::TestCase
88
106
  get = "GET /#{rand_data(10,120)} HTTP/1.1\r\n"
89
107
  get << "X-Test: test\r\n" * (80 * 1024)
90
108
  assert_raises Mongrel::HttpParserError do
91
- parser.execute({}, get)
109
+ parser.execute({}, get, 0)
92
110
  parser.reset
93
111
  end
94
112
 
@@ -96,7 +114,7 @@ class HttpParserTest < Test::Unit::TestCase
96
114
  10.times do |c|
97
115
  get = "GET #{rand_data(1024, 1024+(c*1024), false)} #{rand_data(1024, 1024+(c*1024), false)}\r\n\r\n"
98
116
  assert_raises Mongrel::HttpParserError do
99
- parser.execute({}, get)
117
+ parser.execute({}, get, 0)
100
118
  parser.reset
101
119
  end
102
120
  end
@@ -106,11 +124,11 @@ class HttpParserTest < Test::Unit::TestCase
106
124
 
107
125
 
108
126
  def test_query_parse
109
- res = HttpRequest.query_parse("zed=1&frank=2")
127
+ res = HttpRequest.query_parse("zed=1&frank=#{HttpRequest.escape('&&& ')}")
110
128
  assert res["zed"], "didn't get the request right"
111
129
  assert res["frank"], "no frank"
112
130
  assert_equal "1", res["zed"], "wrong result"
113
- assert_equal "2", res["frank"], "wrong result"
131
+ assert_equal "&&& ", HttpRequest.unescape(res["frank"]), "wrong result"
114
132
 
115
133
  res = HttpRequest.query_parse("zed=1&zed=2&zed=3&frank=11;zed=45")
116
134
  assert res["zed"], "didn't get the request right"
@@ -1,3 +1,21 @@
1
+ # Mongrel Web Server - A Mostly Ruby Webserver and Library
2
+ #
3
+ # Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+
1
19
  require 'test/unit'
2
20
  require 'mongrel'
3
21
  require 'benchmark'
@@ -44,6 +62,26 @@ class ResponseTest < Test::Unit::TestCase
44
62
  assert io.length > 0, "output didn't have data"
45
63
  end
46
64
 
65
+ def test_response_file
66
+ contents = "PLAIN TEXT\r\nCONTENTS\r\n"
67
+ require 'tempfile'
68
+ tmpf = Tempfile.new("test_response_file")
69
+ tmpf.binmode
70
+ tmpf.write(contents)
71
+ tmpf.rewind
47
72
 
73
+ io = StringIO.new
74
+ resp = HttpResponse.new(io)
75
+ resp.start(200) do |head,out|
76
+ head['Content-Type'] = 'text/plain'
77
+ resp.send_header
78
+ resp.send_file(tmpf.path)
79
+ end
80
+ io.rewind
81
+ tmpf.close
82
+
83
+ assert io.length > 0, "output didn't have data"
84
+ assert io.read[-contents.length..-1] == contents, "output doesn't end with file payload"
85
+ end
48
86
  end
49
87
 
@@ -1,5 +1,24 @@
1
+ # Mongrel Web Server - A Mostly Ruby Webserver and Library
2
+ #
3
+ # Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+
1
19
  require 'test/unit'
2
20
  require 'mongrel/stats'
21
+ require 'stringio'
3
22
 
4
23
  class StatsTest < Test::Unit::TestCase
5
24
 
@@ -9,7 +28,7 @@ class StatsTest < Test::Unit::TestCase
9
28
  s = Stats.new("test")
10
29
  t = Stats.new("time")
11
30
 
12
- 10000.times { s.sample(rand(20)); t.tick }
31
+ 100.times { s.sample(rand(20)); t.tick }
13
32
 
14
33
  s.dump("FIRST", out)
15
34
  t.dump("FIRST", out)
@@ -19,7 +38,7 @@ class StatsTest < Test::Unit::TestCase
19
38
 
20
39
  s.reset
21
40
  t.reset
22
- 10000.times { s.sample(rand(20)); t.tick }
41
+ 100.times { s.sample(rand(30)); t.tick }
23
42
 
24
43
  s.dump("SECOND", out)
25
44
  t.dump("SECOND", out)
@@ -1,3 +1,21 @@
1
+ # Mongrel Web Server - A Mostly Ruby Webserver and Library
2
+ #
3
+ # Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+
1
19
  require 'test/unit'
2
20
  require 'net/http'
3
21
  require 'mongrel'
@@ -1,33 +1,119 @@
1
+ # Mongrel Web Server - A Mostly Ruby Webserver and Library
2
+ #
3
+ # Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+
1
19
  require 'test/unit'
2
20
  require 'net/http'
3
21
  require 'mongrel'
4
22
  require 'timeout'
5
-
6
- include Mongrel;
23
+ require File.dirname(__FILE__) + "/testhelp.rb"
7
24
 
8
25
  class TestHandler < Mongrel::HttpHandler
9
- attr_reader :ran_test
10
-
11
- def process(request, response)
12
- @ran_test = true
13
- response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
14
- end
26
+ attr_reader :ran_test
27
+
28
+ def process(request, response)
29
+ @ran_test = true
30
+ response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
31
+ end
15
32
  end
16
-
17
33
 
18
- class WSTest < Test::Unit::TestCase
19
34
 
20
- def test_simple_server
21
- h = HttpServer.new("0.0.0.0", 9998)
22
- tester = TestHandler.new
23
- h.register("/test", tester)
24
- h.run
35
+ class WebServerTest < Test::Unit::TestCase
36
+
37
+ def setup
38
+ @request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
39
+ # we set num_processors=1 so that we can test the reaping code
40
+ @server = HttpServer.new("127.0.0.1", 9998,num_processors=1)
41
+ @tester = TestHandler.new
42
+ @server.register("/test", @tester)
43
+ @server.run
44
+ end
45
+
46
+ def teardown
47
+ @server.stop
48
+ end
49
+
50
+ def test_simple_server
51
+ hit(['http://localhost:9998/test'])
52
+ assert @tester.ran_test, "Handler didn't really run"
53
+ end
54
+
55
+
56
+ def do_test(st, chunk, close_after=nil)
57
+ s = TCPSocket.new("127.0.0.1", 9998);
58
+ req = StringIO.new(st)
59
+ nout = 0
60
+
61
+ while data = req.read(chunk)
62
+ nout += s.write(data)
63
+ s.flush
64
+ sleep 0.2
65
+ if close_after and nout > close_after
66
+ s.close_write
67
+ sleep 1
68
+ end
69
+ end
70
+ s.write(" ") if RUBY_PLATFORM =~ /mswin/
71
+ s.close
72
+ end
73
+
74
+ def test_trickle_attack
75
+ do_test(@request, 3)
76
+ end
77
+
78
+ def test_close_client
79
+ assert_raises IOError do
80
+ do_test(@request, 10, 20)
81
+ end
82
+ end
83
+
84
+ def test_bad_client
85
+ redirect_test_io do
86
+ do_test("GET /test HTTP/BAD", 3)
87
+ end
88
+ end
25
89
 
26
- sleep(1)
27
- res = Net::HTTP.get(URI.parse('http://localhost:9998/test'))
28
- assert res != nil, "Didn't get a response"
29
- assert tester.ran_test, "Handler didn't really run"
90
+ def test_header_is_too_long
91
+ redirect_test_io do
92
+ long = "GET /test HTTP/1.1\r\n" + ("X-Big: stuff\r\n" * 15000) + "\r\n"
93
+ assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL do
94
+ do_test(long, long.length/2)
95
+ end
30
96
  end
97
+ end
98
+
99
+ def test_num_processors_overload
100
+ redirect_test_io do
101
+ assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL do
102
+ tests = [
103
+ Thread.new { do_test(@request, 1) },
104
+ Thread.new { do_test(@request, 10) },
105
+ ]
106
+
107
+ tests.each {|t| t.join}
108
+ end
109
+ end
110
+ end
111
+
112
+ def test_file_streamed_request
113
+ body = "a" * (Mongrel::Const::MAX_BODY * 2)
114
+ long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
115
+ do_test(long, Mongrel::Const::CHUNK_SIZE * 2 -400)
116
+ end
31
117
 
32
118
  end
33
119
 
@@ -0,0 +1,36 @@
1
+ def redirect_test_io
2
+ orig_err = STDERR.dup
3
+ orig_out = STDOUT.dup
4
+ STDERR.reopen("test_stderr.log")
5
+ STDOUT.reopen("test_stdout.log")
6
+
7
+ begin
8
+ yield
9
+ ensure
10
+ STDERR.reopen(orig_err)
11
+ STDOUT.reopen(orig_out)
12
+ end
13
+ end
14
+
15
+
16
+ # Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
17
+ # HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
18
+ def hit(uris)
19
+ results = []
20
+ uris.each do |u|
21
+ res = nil
22
+
23
+ if u.kind_of? String
24
+ res = Net::HTTP.get(URI.parse(u))
25
+ else
26
+ url = URI.parse(u[0])
27
+ res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
28
+ end
29
+
30
+ assert res != nil, "Didn't get a response: #{u}"
31
+ results << res
32
+ end
33
+
34
+ return results
35
+ end
36
+
@@ -1,66 +1,65 @@
1
-
2
1
  def make(makedir)
3
- Dir.chdir(makedir) do
4
- sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
5
- end
2
+ Dir.chdir(makedir) do
3
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
4
+ end
6
5
  end
7
6
 
8
7
 
9
8
  def extconf(dir)
10
- Dir.chdir(dir) do ruby "extconf.rb" end
9
+ Dir.chdir(dir) do ruby "extconf.rb" end
11
10
  end
12
11
 
13
12
 
14
13
  def setup_tests
15
- Rake::TestTask.new do |t|
16
- t.libs << "test"
17
- t.test_files = FileList['test/test*.rb']
18
- t.verbose = true
19
- end
14
+ Rake::TestTask.new do |t|
15
+ t.libs << "test"
16
+ t.test_files = FileList['test/test*.rb']
17
+ t.verbose = true
18
+ end
20
19
  end
21
20
 
22
21
 
23
22
  def setup_clean otherfiles
24
- files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
25
- CLEAN.include(files)
23
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
24
+ CLEAN.include(files)
26
25
  end
27
26
 
28
27
 
29
28
  def setup_rdoc files
30
- Rake::RDocTask.new do |rdoc|
31
- rdoc.rdoc_dir = 'doc/rdoc'
32
- rdoc.options << '--line-numbers'
33
- rdoc.rdoc_files.add(files)
34
- end
29
+ Rake::RDocTask.new do |rdoc|
30
+ rdoc.rdoc_dir = 'doc/rdoc'
31
+ rdoc.options << '--line-numbers'
32
+ rdoc.rdoc_files.add(files)
33
+ end
35
34
  end
36
35
 
37
36
 
38
37
  def setup_extension(dir, extension)
39
- ext = "ext/#{dir}"
40
- ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
41
- ext_files = FileList[
38
+ ext = "ext/#{dir}"
39
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
40
+ ext_files = FileList[
42
41
  "#{ext}/*.c",
43
42
  "#{ext}/*.h",
44
43
  "#{ext}/extconf.rb",
45
44
  "#{ext}/Makefile",
46
45
  "lib"
47
- ]
48
-
49
- task "lib" do
50
- directory "lib"
51
- end
46
+ ]
52
47
 
53
- desc "Builds just the #{extension} extension"
54
- task extension.to_sym => ["#{ext}/Makefile", ext_so ]
48
+ task "lib" do
49
+ directory "lib"
50
+ end
55
51
 
56
- file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
57
- extconf "#{ext}"
58
- end
52
+ desc "Builds just the #{extension} extension"
53
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
59
54
 
60
- file ext_so => ext_files do
61
- make "#{ext}"
62
- cp ext_so, "lib"
63
- end
55
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
56
+ extconf "#{ext}"
57
+ end
58
+
59
+ file ext_so => ext_files do
60
+ make "#{ext}"
61
+ cp ext_so, "lib"
62
+ end
64
63
  end
65
64
 
66
65
 
@@ -74,13 +73,13 @@ def base_gem_spec(pkg_name, pkg_version)
74
73
  s.platform = Gem::Platform::RUBY
75
74
  s.has_rdoc = true
76
75
  s.extra_rdoc_files = [ "README" ]
77
-
76
+
78
77
  s.files = %w(COPYING LICENSE README Rakefile) +
79
78
  Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
80
79
  Dir.glob("ext/**/*.{h,c,rb}") +
81
80
  Dir.glob("examples/**/*.rb") +
82
81
  Dir.glob("tools/*.rb")
83
-
82
+
84
83
  s.require_path = "lib"
85
84
  s.extensions = FileList["ext/**/extconf.rb"].to_a
86
85
  s.bindir = "bin"
@@ -90,22 +89,29 @@ end
90
89
  def setup_gem(pkg_name, pkg_version)
91
90
  spec = base_gem_spec(pkg_name, pkg_version)
92
91
  yield spec if block_given?
93
-
92
+
94
93
  Rake::GemPackageTask.new(spec) do |p|
95
94
  p.gem_spec = spec
96
- p.need_tar = true
95
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
97
96
  end
98
97
  end
99
98
 
100
- def setup_win32_gem(pkg_name, pkg_version)
101
- spec = base_gem_spec(pkg_name, pkg_version)
102
- yield spec if block_given?
103
-
104
- Gem::Builder.new(spec).build
105
- end
106
-
107
99
  def sub_project(project, *targets)
108
100
  targets.each do |target|
109
- sh %{cd projects/#{project}; rake #{target.to_s}; }
101
+ Dir.chdir "projects/#{project}" do
102
+ sh %{rake --trace #{target.to_s} }
103
+ end
104
+ end
105
+ end
106
+
107
+ # Conditional require rcov/rcovtask if present
108
+ begin
109
+ require 'rcov/rcovtask'
110
+
111
+ Rcov::RcovTask.new do |t|
112
+ t.test_files = FileList['test/test*.rb']
113
+ t.rcov_opts << "-x /usr"
114
+ t.output_dir = "test/coverage"
110
115
  end
116
+ rescue Object
111
117
  end