passenger 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (439) hide show
  1. data/NEWS +27 -0
  2. data/README +1 -1
  3. data/bin/passenger-install-nginx-module +3 -1
  4. data/build/config.rb +2 -1
  5. data/build/cxx_tests.rb +7 -3
  6. data/build/documentation.rb +5 -40
  7. data/build/nginx.rb +0 -1
  8. data/build/packaging.rb +0 -6
  9. data/build/rake_extensions.rb +5 -0
  10. data/doc/Architectural overview.html +344 -77
  11. data/doc/Security of user switching support.html +338 -71
  12. data/doc/Users guide Apache with comments.html +4830 -0
  13. data/doc/Users guide Apache.html +695 -428
  14. data/doc/Users guide Apache.idmap.txt +80 -0
  15. data/doc/Users guide Apache.txt +5 -5
  16. data/doc/Users guide Nginx.html +591 -313
  17. data/doc/Users guide Nginx.txt +9 -3
  18. data/doc/Users guide Standalone.html +344 -77
  19. data/ext/boost/src/pthread/thread.cpp +1 -1
  20. data/ext/common/AccountsDatabase.h +1 -1
  21. data/ext/common/Constants.h +2 -2
  22. data/ext/common/Logging.h +2 -1
  23. data/ext/common/LoggingAgent/FilterSupport.h +107 -3
  24. data/ext/common/Session.h +1 -1
  25. data/ext/common/Utils.cpp +2 -0
  26. data/ext/common/Utils/Dechunker.h +232 -0
  27. data/ext/common/Utils/HttpHeaderBufferer.h +165 -0
  28. data/ext/common/Utils/StrIntUtils.cpp +51 -15
  29. data/ext/common/Utils/StrIntUtils.h +3 -0
  30. data/ext/common/Utils/StreamBoyerMooreHorspool.h +506 -0
  31. data/ext/nginx/Configuration.c +36 -282
  32. data/ext/nginx/ContentHandler.c +17 -0
  33. data/ext/nginx/HelperAgent.cpp +397 -39
  34. data/ext/oxt/tracable_exception.cpp +3 -1
  35. data/ext/ruby/extconf.rb +1 -0
  36. data/ext/ruby/passenger_native_support.c +3 -0
  37. data/helper-scripts/prespawn +113 -31
  38. data/lib/phusion_passenger.rb +2 -2
  39. data/lib/phusion_passenger/standalone/runtime_installer.rb +3 -2
  40. data/lib/phusion_passenger/standalone/start_command.rb +12 -12
  41. data/test/cxx/DechunkerTest.cpp +216 -0
  42. data/test/cxx/FilterSupportTest.cpp +31 -4
  43. data/test/cxx/HttpHeaderBuffererTest.cpp +203 -0
  44. data/test/cxx/UtilsTest.cpp +46 -3
  45. data/test/integration_tests/hello_world_rack_spec.rb +7 -0
  46. data/test/stub/rack/config.ru +6 -1
  47. data/test/stub/rails_apps/1.2/empty/public/dispatch.cgi +1 -1
  48. data/test/stub/rails_apps/1.2/empty/public/dispatch.fcgi +1 -1
  49. data/test/stub/rails_apps/1.2/empty/public/dispatch.rb +1 -1
  50. data/test/stub/rails_apps/2.0/empty/public/dispatch.cgi +1 -1
  51. data/test/stub/rails_apps/2.0/empty/public/dispatch.fcgi +1 -1
  52. data/test/stub/rails_apps/2.0/empty/public/dispatch.rb +1 -1
  53. data/test/stub/rails_apps/2.2/empty/public/dispatch.cgi +1 -1
  54. data/test/stub/rails_apps/2.2/empty/public/dispatch.fcgi +1 -1
  55. data/test/stub/rails_apps/2.2/empty/public/dispatch.rb +1 -1
  56. metadata +20 -403
  57. data/doc/Doxyfile +0 -241
  58. data/doc/cxxapi/AbstractSpawnManager_8h_source.html +0 -141
  59. data/doc/cxxapi/Account_8h_source.html +0 -206
  60. data/doc/cxxapi/AccountsDatabase_8h_source.html +0 -161
  61. data/doc/cxxapi/AgentBase_8h_source.html +0 -70
  62. data/doc/cxxapi/AgentsStarter_8h_source.html +0 -112
  63. data/doc/cxxapi/BCrypt_8h_source.html +0 -104
  64. data/doc/cxxapi/Blowfish_8h_source.html +0 -134
  65. data/doc/cxxapi/Bucket_8h_source.html +0 -118
  66. data/doc/cxxapi/Constants_8h_source.html +0 -79
  67. data/doc/cxxapi/ContentHandler_8h_source.html +0 -95
  68. data/doc/cxxapi/DirectoryMapper_8h_source.html +0 -311
  69. data/doc/cxxapi/EventedClient_8h_source.html +0 -733
  70. data/doc/cxxapi/EventedMessageServer_8h_source.html +0 -358
  71. data/doc/cxxapi/EventedServer_8h_source.html +0 -326
  72. data/doc/cxxapi/Exceptions_8h_source.html +0 -393
  73. data/doc/cxxapi/FileDescriptor_8h_source.html +0 -324
  74. data/doc/cxxapi/Hooks_8h_source.html +0 -76
  75. data/doc/cxxapi/HttpStatusExtractor_8h_source.html +0 -382
  76. data/doc/cxxapi/IniFile_8h_source.html +0 -527
  77. data/doc/cxxapi/Logging_8h_source.html +0 -796
  78. data/doc/cxxapi/MessageChannel_8h_source.html +0 -776
  79. data/doc/cxxapi/MessageClient_8h_source.html +0 -328
  80. data/doc/cxxapi/MessageReadersWriters_8h_source.html +0 -539
  81. data/doc/cxxapi/MessageServer_8h_source.html +0 -612
  82. data/doc/cxxapi/PoolOptions_8h_source.html +0 -549
  83. data/doc/cxxapi/Process_8h_source.html +0 -286
  84. data/doc/cxxapi/RandomGenerator_8h_source.html +0 -191
  85. data/doc/cxxapi/ResourceLocator_8h_source.html +0 -166
  86. data/doc/cxxapi/SafeLibev_8h_source.html +0 -180
  87. data/doc/cxxapi/ScgiRequestParser_8h_source.html +0 -406
  88. data/doc/cxxapi/ServerInstanceDir_8h_source.html +0 -378
  89. data/doc/cxxapi/Session_8h_source.html +0 -501
  90. data/doc/cxxapi/SpawnManager_8h_source.html +0 -647
  91. data/doc/cxxapi/StaticContentHandler_8h_source.html +0 -69
  92. data/doc/cxxapi/StaticString_8h_source.html +0 -329
  93. data/doc/cxxapi/StringListCreator_8h_source.html +0 -114
  94. data/doc/cxxapi/Utils_8h_source.html +0 -469
  95. data/doc/cxxapi/annotated.html +0 -87
  96. data/doc/cxxapi/apache2_2Configuration_8h_source.html +0 -82
  97. data/doc/cxxapi/classAgentWatcher-members.html +0 -54
  98. data/doc/cxxapi/classAgentWatcher.html +0 -419
  99. data/doc/cxxapi/classClient-members.html +0 -38
  100. data/doc/cxxapi/classClient.html +0 -123
  101. data/doc/cxxapi/classHooks-members.html +0 -40
  102. data/doc/cxxapi/classHooks.html +0 -153
  103. data/doc/cxxapi/classPassenger_1_1AbstractSpawnManager-members.html +0 -40
  104. data/doc/cxxapi/classPassenger_1_1AbstractSpawnManager.html +0 -187
  105. data/doc/cxxapi/classPassenger_1_1AbstractSpawnManager__inherit__graph.map +0 -3
  106. data/doc/cxxapi/classPassenger_1_1AbstractSpawnManager__inherit__graph.md5 +0 -1
  107. data/doc/cxxapi/classPassenger_1_1AbstractSpawnManager__inherit__graph.png +0 -0
  108. data/doc/cxxapi/classPassenger_1_1ArgumentException-members.html +0 -36
  109. data/doc/cxxapi/classPassenger_1_1ArgumentException.html +0 -56
  110. data/doc/cxxapi/classPassenger_1_1ArrayMessage-members.html +0 -37
  111. data/doc/cxxapi/classPassenger_1_1ArrayMessage.html +0 -113
  112. data/doc/cxxapi/classPassenger_1_1BufferedUpload-members.html +0 -38
  113. data/doc/cxxapi/classPassenger_1_1BufferedUpload.html +0 -112
  114. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +0 -36
  115. data/doc/cxxapi/classPassenger_1_1BusyException.html +0 -54
  116. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +0 -36
  117. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +0 -51
  118. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +0 -41
  119. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +0 -223
  120. data/doc/cxxapi/classPassenger_1_1EOFException-members.html +0 -36
  121. data/doc/cxxapi/classPassenger_1_1EOFException.html +0 -61
  122. data/doc/cxxapi/classPassenger_1_1EOFException__inherit__graph.map +0 -3
  123. data/doc/cxxapi/classPassenger_1_1EOFException__inherit__graph.md5 +0 -1
  124. data/doc/cxxapi/classPassenger_1_1EOFException__inherit__graph.png +0 -0
  125. data/doc/cxxapi/classPassenger_1_1EventFd-members.html +0 -36
  126. data/doc/cxxapi/classPassenger_1_1EventFd.html +0 -52
  127. data/doc/cxxapi/classPassenger_1_1EventedClient-members.html +0 -59
  128. data/doc/cxxapi/classPassenger_1_1EventedClient.html +0 -531
  129. data/doc/cxxapi/classPassenger_1_1EventedMessageServer-members.html +0 -37
  130. data/doc/cxxapi/classPassenger_1_1EventedMessageServer.html +0 -59
  131. data/doc/cxxapi/classPassenger_1_1EventedMessageServer__inherit__graph.map +0 -3
  132. data/doc/cxxapi/classPassenger_1_1EventedMessageServer__inherit__graph.md5 +0 -1
  133. data/doc/cxxapi/classPassenger_1_1EventedMessageServer__inherit__graph.png +0 -0
  134. data/doc/cxxapi/classPassenger_1_1EventedServer-members.html +0 -37
  135. data/doc/cxxapi/classPassenger_1_1EventedServer.html +0 -93
  136. data/doc/cxxapi/classPassenger_1_1EventedServer__inherit__graph.map +0 -3
  137. data/doc/cxxapi/classPassenger_1_1EventedServer__inherit__graph.md5 +0 -1
  138. data/doc/cxxapi/classPassenger_1_1EventedServer__inherit__graph.png +0 -0
  139. data/doc/cxxapi/classPassenger_1_1FileDescriptor-members.html +0 -41
  140. data/doc/cxxapi/classPassenger_1_1FileDescriptor.html +0 -178
  141. data/doc/cxxapi/classPassenger_1_1FileDescriptorPair-members.html +0 -36
  142. data/doc/cxxapi/classPassenger_1_1FileDescriptorPair.html +0 -52
  143. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +0 -36
  144. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +0 -58
  145. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.map +0 -3
  146. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.md5 +0 -1
  147. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
  148. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +0 -41
  149. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +0 -66
  150. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.map +0 -3
  151. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.md5 +0 -1
  152. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
  153. data/doc/cxxapi/classPassenger_1_1HttpStatusExtractor-members.html +0 -39
  154. data/doc/cxxapi/classPassenger_1_1HttpStatusExtractor.html +0 -128
  155. data/doc/cxxapi/classPassenger_1_1IOException-members.html +0 -36
  156. data/doc/cxxapi/classPassenger_1_1IOException.html +0 -61
  157. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.map +0 -4
  158. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.md5 +0 -1
  159. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
  160. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +0 -57
  161. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +0 -839
  162. data/doc/cxxapi/classPassenger_1_1MessageServer-members.html +0 -49
  163. data/doc/cxxapi/classPassenger_1_1MessageServer.html +0 -407
  164. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1ClientContext-members.html +0 -36
  165. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1ClientContext.html +0 -58
  166. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1ClientContext__inherit__graph.map +0 -3
  167. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1ClientContext__inherit__graph.md5 +0 -1
  168. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1ClientContext__inherit__graph.png +0 -0
  169. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1CommonClientContext-members.html +0 -41
  170. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1CommonClientContext.html +0 -165
  171. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1CommonClientContext__inherit__graph.map +0 -3
  172. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1CommonClientContext__inherit__graph.md5 +0 -1
  173. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1CommonClientContext__inherit__graph.png +0 -0
  174. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1Handler-members.html +0 -39
  175. data/doc/cxxapi/classPassenger_1_1MessageServer_1_1Handler.html +0 -173
  176. data/doc/cxxapi/classPassenger_1_1Process-members.html +0 -44
  177. data/doc/cxxapi/classPassenger_1_1Process.html +0 -290
  178. data/doc/cxxapi/classPassenger_1_1RandomGenerator-members.html +0 -37
  179. data/doc/cxxapi/classPassenger_1_1RandomGenerator.html +0 -79
  180. data/doc/cxxapi/classPassenger_1_1ResourceLocator-members.html +0 -36
  181. data/doc/cxxapi/classPassenger_1_1ResourceLocator.html +0 -51
  182. data/doc/cxxapi/classPassenger_1_1RuntimeException-members.html +0 -36
  183. data/doc/cxxapi/classPassenger_1_1RuntimeException.html +0 -54
  184. data/doc/cxxapi/classPassenger_1_1SafeLibev-members.html +0 -36
  185. data/doc/cxxapi/classPassenger_1_1SafeLibev.html +0 -51
  186. data/doc/cxxapi/classPassenger_1_1ScalarMessage-members.html +0 -37
  187. data/doc/cxxapi/classPassenger_1_1ScalarMessage.html +0 -76
  188. data/doc/cxxapi/classPassenger_1_1ScgiRequestParser-members.html +0 -50
  189. data/doc/cxxapi/classPassenger_1_1ScgiRequestParser.html +0 -285
  190. data/doc/cxxapi/classPassenger_1_1SecurityException-members.html +0 -36
  191. data/doc/cxxapi/classPassenger_1_1SecurityException.html +0 -56
  192. data/doc/cxxapi/classPassenger_1_1Session-members.html +0 -53
  193. data/doc/cxxapi/classPassenger_1_1Session.html +0 -556
  194. data/doc/cxxapi/classPassenger_1_1Session__inherit__graph.map +0 -3
  195. data/doc/cxxapi/classPassenger_1_1Session__inherit__graph.md5 +0 -1
  196. data/doc/cxxapi/classPassenger_1_1Session__inherit__graph.png +0 -0
  197. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +0 -39
  198. data/doc/cxxapi/classPassenger_1_1SpawnException.html +0 -101
  199. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +0 -42
  200. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +0 -292
  201. data/doc/cxxapi/classPassenger_1_1SpawnManager__inherit__graph.map +0 -3
  202. data/doc/cxxapi/classPassenger_1_1SpawnManager__inherit__graph.md5 +0 -1
  203. data/doc/cxxapi/classPassenger_1_1SpawnManager__inherit__graph.png +0 -0
  204. data/doc/cxxapi/classPassenger_1_1StandardSession-members.html +0 -54
  205. data/doc/cxxapi/classPassenger_1_1StandardSession.html +0 -394
  206. data/doc/cxxapi/classPassenger_1_1StandardSession__inherit__graph.map +0 -3
  207. data/doc/cxxapi/classPassenger_1_1StandardSession__inherit__graph.md5 +0 -1
  208. data/doc/cxxapi/classPassenger_1_1StandardSession__inherit__graph.png +0 -0
  209. data/doc/cxxapi/classPassenger_1_1StaticString-members.html +0 -36
  210. data/doc/cxxapi/classPassenger_1_1StaticString.html +0 -56
  211. data/doc/cxxapi/classPassenger_1_1SyntaxError-members.html +0 -36
  212. data/doc/cxxapi/classPassenger_1_1SyntaxError.html +0 -54
  213. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +0 -40
  214. data/doc/cxxapi/classPassenger_1_1SystemException.html +0 -155
  215. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.map +0 -4
  216. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.md5 +0 -1
  217. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
  218. data/doc/cxxapi/classPassenger_1_1TimeRetrievalException-members.html +0 -40
  219. data/doc/cxxapi/classPassenger_1_1TimeRetrievalException.html +0 -61
  220. data/doc/cxxapi/classPassenger_1_1TimeRetrievalException__inherit__graph.map +0 -3
  221. data/doc/cxxapi/classPassenger_1_1TimeRetrievalException__inherit__graph.md5 +0 -1
  222. data/doc/cxxapi/classPassenger_1_1TimeRetrievalException__inherit__graph.png +0 -0
  223. data/doc/cxxapi/classPassenger_1_1TimeoutException-members.html +0 -36
  224. data/doc/cxxapi/classPassenger_1_1TimeoutException.html +0 -54
  225. data/doc/cxxapi/classPassenger_1_1Uint16Message-members.html +0 -36
  226. data/doc/cxxapi/classPassenger_1_1Uint16Message.html +0 -51
  227. data/doc/cxxapi/classPassenger_1_1Uint32Message-members.html +0 -36
  228. data/doc/cxxapi/classPassenger_1_1Uint32Message.html +0 -51
  229. data/doc/cxxapi/classServer-members.html +0 -36
  230. data/doc/cxxapi/classServer.html +0 -49
  231. data/doc/cxxapi/classServerInstanceDirToucher-members.html +0 -36
  232. data/doc/cxxapi/classServerInstanceDirToucher.html +0 -47
  233. data/doc/cxxapi/classes.html +0 -52
  234. data/doc/cxxapi/definitions_8h_source.html +0 -36
  235. data/doc/cxxapi/doxygen.css +0 -532
  236. data/doc/cxxapi/doxygen.png +0 -0
  237. data/doc/cxxapi/files.html +0 -76
  238. data/doc/cxxapi/ftv2blank.png +0 -0
  239. data/doc/cxxapi/ftv2doc.png +0 -0
  240. data/doc/cxxapi/ftv2folderclosed.png +0 -0
  241. data/doc/cxxapi/ftv2folderopen.png +0 -0
  242. data/doc/cxxapi/ftv2lastnode.png +0 -0
  243. data/doc/cxxapi/ftv2link.png +0 -0
  244. data/doc/cxxapi/ftv2mlastnode.png +0 -0
  245. data/doc/cxxapi/ftv2mnode.png +0 -0
  246. data/doc/cxxapi/ftv2node.png +0 -0
  247. data/doc/cxxapi/ftv2plastnode.png +0 -0
  248. data/doc/cxxapi/ftv2pnode.png +0 -0
  249. data/doc/cxxapi/ftv2vertline.png +0 -0
  250. data/doc/cxxapi/functions.html +0 -103
  251. data/doc/cxxapi/functions_0x62.html +0 -82
  252. data/doc/cxxapi/functions_0x63.html +0 -102
  253. data/doc/cxxapi/functions_0x64.html +0 -102
  254. data/doc/cxxapi/functions_0x65.html +0 -88
  255. data/doc/cxxapi/functions_0x66.html +0 -100
  256. data/doc/cxxapi/functions_0x67.html +0 -167
  257. data/doc/cxxapi/functions_0x68.html +0 -88
  258. data/doc/cxxapi/functions_0x69.html +0 -96
  259. data/doc/cxxapi/functions_0x6b.html +0 -80
  260. data/doc/cxxapi/functions_0x6c.html +0 -88
  261. data/doc/cxxapi/functions_0x6d.html +0 -88
  262. data/doc/cxxapi/functions_0x6e.html +0 -86
  263. data/doc/cxxapi/functions_0x6f.html +0 -94
  264. data/doc/cxxapi/functions_0x70.html +0 -94
  265. data/doc/cxxapi/functions_0x72.html +0 -110
  266. data/doc/cxxapi/functions_0x73.html +0 -171
  267. data/doc/cxxapi/functions_0x74.html +0 -85
  268. data/doc/cxxapi/functions_0x75.html +0 -85
  269. data/doc/cxxapi/functions_0x77.html +0 -92
  270. data/doc/cxxapi/functions_0x7e.html +0 -79
  271. data/doc/cxxapi/functions_enum.html +0 -49
  272. data/doc/cxxapi/functions_eval.html +0 -67
  273. data/doc/cxxapi/functions_func.html +0 -531
  274. data/doc/cxxapi/functions_vars.html +0 -278
  275. data/doc/cxxapi/graph_legend.dot +0 -22
  276. data/doc/cxxapi/graph_legend.html +0 -92
  277. data/doc/cxxapi/graph_legend.png +0 -0
  278. data/doc/cxxapi/group__Core.html +0 -46
  279. data/doc/cxxapi/group__Core.map +0 -3
  280. data/doc/cxxapi/group__Core.png +0 -0
  281. data/doc/cxxapi/group__Exceptions.html +0 -53
  282. data/doc/cxxapi/group__Hooks.html +0 -42
  283. data/doc/cxxapi/group__Hooks.map +0 -3
  284. data/doc/cxxapi/group__Hooks.png +0 -0
  285. data/doc/cxxapi/group__Support.html +0 -538
  286. data/doc/cxxapi/hierarchy.html +0 -101
  287. data/doc/cxxapi/index.html +0 -16
  288. data/doc/cxxapi/inherit__graph__0.map +0 -3
  289. data/doc/cxxapi/inherit__graph__0.md5 +0 -1
  290. data/doc/cxxapi/inherit__graph__0.png +0 -0
  291. data/doc/cxxapi/inherit__graph__1.map +0 -3
  292. data/doc/cxxapi/inherit__graph__1.md5 +0 -1
  293. data/doc/cxxapi/inherit__graph__1.png +0 -0
  294. data/doc/cxxapi/inherit__graph__10.map +0 -3
  295. data/doc/cxxapi/inherit__graph__10.md5 +0 -1
  296. data/doc/cxxapi/inherit__graph__10.png +0 -0
  297. data/doc/cxxapi/inherit__graph__11.map +0 -4
  298. data/doc/cxxapi/inherit__graph__11.md5 +0 -1
  299. data/doc/cxxapi/inherit__graph__11.png +0 -0
  300. data/doc/cxxapi/inherit__graph__12.map +0 -3
  301. data/doc/cxxapi/inherit__graph__12.md5 +0 -1
  302. data/doc/cxxapi/inherit__graph__12.png +0 -0
  303. data/doc/cxxapi/inherit__graph__13.map +0 -3
  304. data/doc/cxxapi/inherit__graph__13.md5 +0 -1
  305. data/doc/cxxapi/inherit__graph__13.png +0 -0
  306. data/doc/cxxapi/inherit__graph__14.map +0 -3
  307. data/doc/cxxapi/inherit__graph__14.md5 +0 -1
  308. data/doc/cxxapi/inherit__graph__14.png +0 -0
  309. data/doc/cxxapi/inherit__graph__15.map +0 -3
  310. data/doc/cxxapi/inherit__graph__15.md5 +0 -1
  311. data/doc/cxxapi/inherit__graph__15.png +0 -0
  312. data/doc/cxxapi/inherit__graph__16.map +0 -5
  313. data/doc/cxxapi/inherit__graph__16.md5 +0 -1
  314. data/doc/cxxapi/inherit__graph__16.png +0 -0
  315. data/doc/cxxapi/inherit__graph__17.map +0 -3
  316. data/doc/cxxapi/inherit__graph__17.md5 +0 -1
  317. data/doc/cxxapi/inherit__graph__17.png +0 -0
  318. data/doc/cxxapi/inherit__graph__18.map +0 -3
  319. data/doc/cxxapi/inherit__graph__18.md5 +0 -1
  320. data/doc/cxxapi/inherit__graph__18.png +0 -0
  321. data/doc/cxxapi/inherit__graph__19.map +0 -4
  322. data/doc/cxxapi/inherit__graph__19.md5 +0 -1
  323. data/doc/cxxapi/inherit__graph__19.png +0 -0
  324. data/doc/cxxapi/inherit__graph__2.map +0 -3
  325. data/doc/cxxapi/inherit__graph__2.md5 +0 -1
  326. data/doc/cxxapi/inherit__graph__2.png +0 -0
  327. data/doc/cxxapi/inherit__graph__20.map +0 -3
  328. data/doc/cxxapi/inherit__graph__20.md5 +0 -1
  329. data/doc/cxxapi/inherit__graph__20.png +0 -0
  330. data/doc/cxxapi/inherit__graph__21.map +0 -3
  331. data/doc/cxxapi/inherit__graph__21.md5 +0 -1
  332. data/doc/cxxapi/inherit__graph__21.png +0 -0
  333. data/doc/cxxapi/inherit__graph__22.map +0 -3
  334. data/doc/cxxapi/inherit__graph__22.md5 +0 -1
  335. data/doc/cxxapi/inherit__graph__22.png +0 -0
  336. data/doc/cxxapi/inherit__graph__23.map +0 -3
  337. data/doc/cxxapi/inherit__graph__23.md5 +0 -1
  338. data/doc/cxxapi/inherit__graph__23.png +0 -0
  339. data/doc/cxxapi/inherit__graph__24.map +0 -3
  340. data/doc/cxxapi/inherit__graph__24.md5 +0 -1
  341. data/doc/cxxapi/inherit__graph__24.png +0 -0
  342. data/doc/cxxapi/inherit__graph__25.map +0 -3
  343. data/doc/cxxapi/inherit__graph__25.md5 +0 -1
  344. data/doc/cxxapi/inherit__graph__25.png +0 -0
  345. data/doc/cxxapi/inherit__graph__26.map +0 -3
  346. data/doc/cxxapi/inherit__graph__26.md5 +0 -1
  347. data/doc/cxxapi/inherit__graph__26.png +0 -0
  348. data/doc/cxxapi/inherit__graph__27.map +0 -3
  349. data/doc/cxxapi/inherit__graph__27.md5 +0 -1
  350. data/doc/cxxapi/inherit__graph__27.png +0 -0
  351. data/doc/cxxapi/inherit__graph__28.map +0 -3
  352. data/doc/cxxapi/inherit__graph__28.md5 +0 -1
  353. data/doc/cxxapi/inherit__graph__28.png +0 -0
  354. data/doc/cxxapi/inherit__graph__29.map +0 -3
  355. data/doc/cxxapi/inherit__graph__29.md5 +0 -1
  356. data/doc/cxxapi/inherit__graph__29.png +0 -0
  357. data/doc/cxxapi/inherit__graph__3.map +0 -4
  358. data/doc/cxxapi/inherit__graph__3.md5 +0 -1
  359. data/doc/cxxapi/inherit__graph__3.png +0 -0
  360. data/doc/cxxapi/inherit__graph__30.map +0 -3
  361. data/doc/cxxapi/inherit__graph__30.md5 +0 -1
  362. data/doc/cxxapi/inherit__graph__30.png +0 -0
  363. data/doc/cxxapi/inherit__graph__31.map +0 -4
  364. data/doc/cxxapi/inherit__graph__31.md5 +0 -1
  365. data/doc/cxxapi/inherit__graph__31.png +0 -0
  366. data/doc/cxxapi/inherit__graph__32.map +0 -3
  367. data/doc/cxxapi/inherit__graph__32.md5 +0 -1
  368. data/doc/cxxapi/inherit__graph__32.png +0 -0
  369. data/doc/cxxapi/inherit__graph__33.map +0 -3
  370. data/doc/cxxapi/inherit__graph__33.md5 +0 -1
  371. data/doc/cxxapi/inherit__graph__33.png +0 -0
  372. data/doc/cxxapi/inherit__graph__34.map +0 -3
  373. data/doc/cxxapi/inherit__graph__34.md5 +0 -1
  374. data/doc/cxxapi/inherit__graph__34.png +0 -0
  375. data/doc/cxxapi/inherit__graph__35.map +0 -3
  376. data/doc/cxxapi/inherit__graph__35.md5 +0 -1
  377. data/doc/cxxapi/inherit__graph__35.png +0 -0
  378. data/doc/cxxapi/inherit__graph__36.map +0 -5
  379. data/doc/cxxapi/inherit__graph__36.md5 +0 -1
  380. data/doc/cxxapi/inherit__graph__36.png +0 -0
  381. data/doc/cxxapi/inherit__graph__37.map +0 -3
  382. data/doc/cxxapi/inherit__graph__37.md5 +0 -1
  383. data/doc/cxxapi/inherit__graph__37.png +0 -0
  384. data/doc/cxxapi/inherit__graph__38.map +0 -3
  385. data/doc/cxxapi/inherit__graph__38.md5 +0 -1
  386. data/doc/cxxapi/inherit__graph__38.png +0 -0
  387. data/doc/cxxapi/inherit__graph__39.map +0 -3
  388. data/doc/cxxapi/inherit__graph__39.md5 +0 -1
  389. data/doc/cxxapi/inherit__graph__39.png +0 -0
  390. data/doc/cxxapi/inherit__graph__4.map +0 -3
  391. data/doc/cxxapi/inherit__graph__4.md5 +0 -1
  392. data/doc/cxxapi/inherit__graph__4.png +0 -0
  393. data/doc/cxxapi/inherit__graph__40.map +0 -3
  394. data/doc/cxxapi/inherit__graph__40.md5 +0 -1
  395. data/doc/cxxapi/inherit__graph__40.png +0 -0
  396. data/doc/cxxapi/inherit__graph__41.map +0 -3
  397. data/doc/cxxapi/inherit__graph__41.md5 +0 -1
  398. data/doc/cxxapi/inherit__graph__41.png +0 -0
  399. data/doc/cxxapi/inherit__graph__5.map +0 -3
  400. data/doc/cxxapi/inherit__graph__5.md5 +0 -1
  401. data/doc/cxxapi/inherit__graph__5.png +0 -0
  402. data/doc/cxxapi/inherit__graph__6.map +0 -3
  403. data/doc/cxxapi/inherit__graph__6.md5 +0 -1
  404. data/doc/cxxapi/inherit__graph__6.png +0 -0
  405. data/doc/cxxapi/inherit__graph__7.map +0 -3
  406. data/doc/cxxapi/inherit__graph__7.md5 +0 -1
  407. data/doc/cxxapi/inherit__graph__7.png +0 -0
  408. data/doc/cxxapi/inherit__graph__8.map +0 -3
  409. data/doc/cxxapi/inherit__graph__8.md5 +0 -1
  410. data/doc/cxxapi/inherit__graph__8.png +0 -0
  411. data/doc/cxxapi/inherit__graph__9.map +0 -3
  412. data/doc/cxxapi/inherit__graph__9.md5 +0 -1
  413. data/doc/cxxapi/inherit__graph__9.png +0 -0
  414. data/doc/cxxapi/inherits.html +0 -165
  415. data/doc/cxxapi/main.html +0 -28
  416. data/doc/cxxapi/modules.html +0 -36
  417. data/doc/cxxapi/namespacePassenger.html +0 -585
  418. data/doc/cxxapi/namespacemembers.html +0 -190
  419. data/doc/cxxapi/namespacemembers_enum.html +0 -48
  420. data/doc/cxxapi/namespacemembers_eval.html +0 -57
  421. data/doc/cxxapi/namespacemembers_func.html +0 -114
  422. data/doc/cxxapi/namespacemembers_type.html +0 -54
  423. data/doc/cxxapi/namespaces.html +0 -37
  424. data/doc/cxxapi/nginx_2Configuration_8h_source.html +0 -126
  425. data/doc/cxxapi/ngx__http__passenger__module_8h_source.html +0 -95
  426. data/doc/cxxapi/structPassenger_1_1MessageServer_1_1DisconnectEventBroadcastGuard-members.html +0 -36
  427. data/doc/cxxapi/structPassenger_1_1MessageServer_1_1DisconnectEventBroadcastGuard.html +0 -51
  428. data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +0 -67
  429. data/doc/cxxapi/structPassenger_1_1PoolOptions.html +0 -647
  430. data/doc/cxxapi/structPassenger_1_1StaticString_1_1Hash-members.html +0 -36
  431. data/doc/cxxapi/structPassenger_1_1StaticString_1_1Hash.html +0 -51
  432. data/doc/cxxapi/tab_b.gif +0 -0
  433. data/doc/cxxapi/tab_l.gif +0 -0
  434. data/doc/cxxapi/tab_r.gif +0 -0
  435. data/doc/cxxapi/tabs.css +0 -105
  436. data/doc/cxxapi/tree.html +0 -249
  437. data/doc/template/horo.rb +0 -613
  438. data/ext/libev/config.h +0 -122
  439. data/ext/nginx/HttpStatusExtractor.h +0 -351
@@ -339,7 +339,7 @@ namespace boost
339
339
  if(thread_info)
340
340
  {
341
341
  unique_lock<mutex> lk(thread_info->sleep_mutex);
342
- while(thread_info->sleep_condition.timed_wait(lk,st));
342
+ while(thread_info->sleep_condition.timed_wait(lk,st)) {};
343
343
  }
344
344
  else
345
345
  {
@@ -61,7 +61,7 @@ public:
61
61
 
62
62
  unsigned int size() const {
63
63
  lock_guard<boost::mutex> l(lock);
64
- return accounts.size();
64
+ return (unsigned int) accounts.size();
65
65
  }
66
66
 
67
67
  vector<string> listUsernames() const {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - http://www.modrails.com/
3
- * Copyright (c) 2010 Phusion
3
+ * Copyright (c) 2010, 2011 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -26,7 +26,7 @@
26
26
  #define _PASSENGER_CONSTANTS_H_
27
27
 
28
28
  /* Don't forget to update lib/phusion_passenger.rb too. */
29
- #define PASSENGER_VERSION "3.0.7"
29
+ #define PASSENGER_VERSION "3.0.8"
30
30
 
31
31
  #define FEEDBACK_FD 3
32
32
 
@@ -42,6 +42,7 @@
42
42
  #include <sstream>
43
43
  #include <cstdio>
44
44
  #include <ctime>
45
+ #include <cerrno>
45
46
 
46
47
  #include "RandomGenerator.h"
47
48
  #include "FileDescriptor.h"
@@ -149,7 +150,7 @@ void setDebugFile(const char *logFile = NULL);
149
150
  #endif
150
151
 
151
152
 
152
- /********** Transaction logging facilities *********/
153
+ /********** Analytics logging facilities *********/
153
154
 
154
155
  struct AnalyticsLoggerSharedData {
155
156
  boost::mutex lock;
@@ -33,7 +33,9 @@
33
33
 
34
34
  #include <string>
35
35
  #include <set>
36
- #include <regex.h>
36
+ #ifndef _PCREPOSIX_H
37
+ #include <regex.h>
38
+ #endif
37
39
  #include <cstdio>
38
40
  #include <cstring>
39
41
 
@@ -475,7 +477,11 @@ public:
475
477
  enum FieldIdentifier {
476
478
  URI,
477
479
  CONTROLLER,
478
- RESPONSE_TIME
480
+ RESPONSE_TIME,
481
+ RESPONSE_TIME_WITHOUT_GC,
482
+ STATUS,
483
+ STATUS_CODE,
484
+ GC_TIME
479
485
  };
480
486
 
481
487
  virtual ~Context() { }
@@ -483,8 +489,15 @@ public:
483
489
  virtual string getURI() const = 0;
484
490
  virtual string getController() const = 0;
485
491
  virtual int getResponseTime() const = 0;
492
+ virtual string getStatus() const = 0;
493
+ virtual int getStatusCode() const = 0;
494
+ virtual int getGcTime() const = 0;
486
495
  virtual bool hasHint(const string &name) const = 0;
487
496
 
497
+ int getResponseTimeWithoutGc() const {
498
+ return getResponseTime() - getGcTime();
499
+ }
500
+
488
501
  string queryStringField(FieldIdentifier id) const {
489
502
  switch (id) {
490
503
  case URI:
@@ -493,6 +506,14 @@ public:
493
506
  return getController();
494
507
  case RESPONSE_TIME:
495
508
  return toString(getResponseTime());
509
+ case RESPONSE_TIME_WITHOUT_GC:
510
+ return toString(getResponseTimeWithoutGc());
511
+ case STATUS:
512
+ return getStatus();
513
+ case STATUS_CODE:
514
+ return toString(getStatusCode());
515
+ case GC_TIME:
516
+ return toString(getGcTime());
496
517
  default:
497
518
  return "";
498
519
  }
@@ -502,6 +523,12 @@ public:
502
523
  switch (id) {
503
524
  case RESPONSE_TIME:
504
525
  return getResponseTime();
526
+ case RESPONSE_TIME_WITHOUT_GC:
527
+ return getResponseTimeWithoutGc();
528
+ case STATUS_CODE:
529
+ return getStatusCode();
530
+ case GC_TIME:
531
+ return getGcTime();
505
532
  default:
506
533
  return 0;
507
534
  }
@@ -515,6 +542,14 @@ public:
515
542
  return !getController().empty();
516
543
  case RESPONSE_TIME:
517
544
  return getResponseTime() > 0;
545
+ case RESPONSE_TIME_WITHOUT_GC:
546
+ return getResponseTimeWithoutGc() > 0;
547
+ case STATUS:
548
+ return !getStatus().empty();
549
+ case STATUS_CODE:
550
+ return getStatusCode() > 0;
551
+ case GC_TIME:
552
+ return getGcTime() > 0;
518
553
  default:
519
554
  return false;
520
555
  }
@@ -524,8 +559,12 @@ public:
524
559
  switch (id) {
525
560
  case URI:
526
561
  case CONTROLLER:
562
+ case STATUS:
527
563
  return STRING_TYPE;
528
564
  case RESPONSE_TIME:
565
+ case RESPONSE_TIME_WITHOUT_GC:
566
+ case STATUS_CODE:
567
+ case GC_TIME:
529
568
  return INTEGER_TYPE;
530
569
  default:
531
570
  return UNKNOWN_TYPE;
@@ -537,11 +576,16 @@ class SimpleContext: public Context {
537
576
  public:
538
577
  string uri;
539
578
  string controller;
579
+ string status;
540
580
  int responseTime;
581
+ int statusCode;
582
+ int gcTime;
541
583
  set<string> hints;
542
584
 
543
585
  SimpleContext() {
544
586
  responseTime = 0;
587
+ statusCode = 0;
588
+ gcTime = 0;
545
589
  }
546
590
 
547
591
  virtual string getURI() const {
@@ -556,6 +600,18 @@ public:
556
600
  return responseTime;
557
601
  }
558
602
 
603
+ virtual string getStatus() const {
604
+ return status;
605
+ }
606
+
607
+ virtual int getStatusCode() const {
608
+ return statusCode;
609
+ }
610
+
611
+ virtual int getGcTime() const {
612
+ return gcTime;
613
+ }
614
+
559
615
  virtual bool hasHint(const string &name) const {
560
616
  return hints.find(name) != hints.end();
561
617
  }
@@ -569,6 +625,10 @@ private:
569
625
  struct ParseState {
570
626
  unsigned long long requestProcessingStart;
571
627
  unsigned long long requestProcessingEnd;
628
+ unsigned long long smallestTimestamp;
629
+ unsigned long long largestTimestamp;
630
+ unsigned long long gcTimeStart;
631
+ unsigned long long gcTimeEnd;
572
632
  };
573
633
 
574
634
  static void parseLine(const StaticString &txnId, unsigned long long timestamp,
@@ -587,15 +647,33 @@ private:
587
647
  if (pos != string::npos) {
588
648
  ctx.controller = value.substr(0, pos);
589
649
  }
650
+ } else if (startsWith(data, "Status: ")) {
651
+ StaticString value = data.substr(data.find(':') + 2);
652
+ ctx.status = value;
653
+ ctx.statusCode = stringToInt(value);
654
+ } else if (startsWith(data, "Initial GC time: ")) {
655
+ StaticString value = data.substr(data.find(':') + 2);
656
+ state.gcTimeStart = stringToULL(value);
657
+ } else if (startsWith(data, "Final GC time: ")) {
658
+ StaticString value = data.substr(data.find(':') + 2);
659
+ state.gcTimeEnd = stringToULL(value);
660
+ }
661
+
662
+ if (state.smallestTimestamp == 0 || timestamp < state.smallestTimestamp) {
663
+ state.smallestTimestamp = timestamp;
664
+ }
665
+ if (timestamp > state.largestTimestamp) {
666
+ state.largestTimestamp = timestamp;
590
667
  }
591
668
  }
592
669
 
593
670
  static void reallyParse(const StaticString &data, SimpleContext &ctx) {
594
671
  const char *current = data.data();
595
672
  const char *end = data.data() + data.size();
596
- ParseState state;
597
673
 
674
+ ParseState state;
598
675
  memset(&state, 0, sizeof(state));
676
+
599
677
  while (current < end) {
600
678
  current = skipNewlines(current, end);
601
679
  if (current < end) {
@@ -622,6 +700,12 @@ private:
622
700
  if (state.requestProcessingEnd != 0) {
623
701
  ctx.responseTime = int(state.requestProcessingEnd -
624
702
  state.requestProcessingStart);
703
+ } else if (state.smallestTimestamp != 0) {
704
+ ctx.responseTime = state.largestTimestamp - state.smallestTimestamp;
705
+ }
706
+
707
+ if (state.gcTimeEnd != 0) {
708
+ ctx.gcTime = state.gcTimeEnd - state.gcTimeStart;
625
709
  }
626
710
  }
627
711
 
@@ -723,6 +807,18 @@ public:
723
807
  return parse()->getResponseTime();
724
808
  }
725
809
 
810
+ virtual string getStatus() const {
811
+ return parse()->getStatus();
812
+ }
813
+
814
+ virtual int getStatusCode() const {
815
+ return parse()->getStatusCode();
816
+ }
817
+
818
+ virtual int getGcTime() const {
819
+ return parse()->getGcTime();
820
+ }
821
+
726
822
  virtual bool hasHint(const string &name) const {
727
823
  return parse()->hasHint(name);
728
824
  }
@@ -1458,6 +1554,14 @@ private:
1458
1554
  return Value(Context::CONTROLLER);
1459
1555
  } else if (token.rawValue == "response_time") {
1460
1556
  return Value(Context::RESPONSE_TIME);
1557
+ } else if (token.rawValue == "response_time_without_gc") {
1558
+ return Value(Context::RESPONSE_TIME_WITHOUT_GC);
1559
+ } else if (token.rawValue == "status") {
1560
+ return Value(Context::STATUS);
1561
+ } else if (token.rawValue == "status_code") {
1562
+ return Value(Context::STATUS_CODE);
1563
+ } else if (token.rawValue == "gc_time") {
1564
+ return Value(Context::GC_TIME);
1461
1565
  } else {
1462
1566
  raiseSyntaxError("unknown field '" + token.rawValue + "'", token);
1463
1567
  return Value(); // Shut up compiler warning.
@@ -176,7 +176,7 @@ public:
176
176
  * @throws boost::thread_interrupted
177
177
  */
178
178
  virtual void sendHeaders(const StaticString &headers) {
179
- sendHeaders(headers.c_str(), headers.size());
179
+ sendHeaders(headers.c_str(), (unsigned int) headers.size());
180
180
  }
181
181
 
182
182
  /**
@@ -49,6 +49,7 @@
49
49
  #include <Utils/Base64.h>
50
50
  #include <Utils/CachedFileStat.hpp>
51
51
  #include <Utils/StrIntUtils.h>
52
+ #include <Utils/HttpHeaderBufferer.h>
52
53
 
53
54
  #ifndef HOST_NAME_MAX
54
55
  #if defined(_POSIX_HOST_NAME_MAX)
@@ -68,6 +69,7 @@
68
69
  namespace Passenger {
69
70
 
70
71
  static string passengerTempDir;
72
+ HttpHeaderBufferer::StaticData HttpHeaderBufferer::staticData;
71
73
 
72
74
  namespace {
73
75
  /**
@@ -0,0 +1,232 @@
1
+ #ifndef _PASSENGER_DECHUNKER_H_
2
+ #define _PASSENGER_DECHUNKER_H_
3
+
4
+ #include <algorithm>
5
+ #include <cstddef>
6
+ #include <cstdlib>
7
+ #include <cstring>
8
+
9
+ #include <StaticString.h>
10
+ #include <Utils/StrIntUtils.h>
11
+
12
+ namespace Passenger {
13
+
14
+ using namespace std;
15
+
16
+
17
+ /**
18
+ * Parses data in HTTP/1.1 chunked transfer encoding.
19
+ *
20
+ * Feed data into this parser by calling feed(). Do this until acceptingInput()
21
+ * is false. Any data chunks it has parsed will be emitted through the onData
22
+ * callback. This parser is zero-copy so the callback arguments point to the
23
+ * fed data.
24
+ *
25
+ * Dechunker parses until the terminating chunk or until a parse error occurs.
26
+ * After that it will refuse to accept new data until reset() is called.
27
+ */
28
+ class Dechunker {
29
+ public:
30
+ typedef void (*Callback)(const char *data, size_t size, void *userData);
31
+
32
+ private:
33
+ static const char CR = '\x0D';
34
+ static const char LF = '\x0A';
35
+
36
+ char sizeBuffer[10];
37
+ unsigned int sizeBufferLen;
38
+ unsigned int remainingDataSize;
39
+ const char *errorMessage;
40
+
41
+ enum {
42
+ EXPECTING_SIZE,
43
+ EXPECTING_CHUNK_EXTENSION,
44
+ EXPECTING_HEADER_LF,
45
+ EXPECTING_DATA,
46
+ EXPECTING_NON_FINAL_CR,
47
+ EXPECTING_NON_FINAL_LF,
48
+ EXPECTING_FINAL_CR,
49
+ EXPECTING_FINAL_LF,
50
+ DONE,
51
+ ERROR
52
+ } state;
53
+
54
+ void setError(const char *message) {
55
+ errorMessage = message;
56
+ state = ERROR;
57
+ }
58
+
59
+ bool isDigit(char ch) const {
60
+ return (ch >= '0' && ch <= '9')
61
+ || (ch >= 'a' && ch <= 'f')
62
+ || (ch >= 'A' && ch <= 'Z');
63
+ }
64
+
65
+ void parseSizeBuffer() {
66
+ remainingDataSize = hexToUint(StaticString(sizeBuffer, sizeBufferLen));
67
+ }
68
+
69
+ void emitDataEvent(const char *data, size_t size) const {
70
+ if (onData != NULL) {
71
+ onData(data, size, userData);
72
+ }
73
+ }
74
+
75
+ public:
76
+ Callback onData;
77
+ void *userData;
78
+
79
+ Dechunker() {
80
+ onData = NULL;
81
+ userData = NULL;
82
+ reset();
83
+ }
84
+
85
+ /**
86
+ * Resets the internal state so that this Dechunker can be reused
87
+ * for parsing new data.
88
+ *
89
+ * @post acceptingInput()
90
+ * @post !hasError()
91
+ */
92
+ void reset() {
93
+ state = EXPECTING_SIZE;
94
+ sizeBufferLen = 0;
95
+ remainingDataSize = 0;
96
+ errorMessage = NULL;
97
+ }
98
+
99
+ /**
100
+ * Feeds data into this parser. Any data chunks it has parsed will be emitted
101
+ * through the onData callback. Returns the number of bytes that have been
102
+ * accepted. Any data not recognized as part of the chunked transfer encoding
103
+ * stream will be rejected.
104
+ */
105
+ size_t feed(const char *data, size_t size) {
106
+ const char *current = data;
107
+ const char *end = data + size;
108
+ const char *needle;
109
+ size_t dataSize;
110
+
111
+ while (current < end && state != DONE && state != ERROR) {
112
+ switch (state) {
113
+ case EXPECTING_DATA:
114
+ dataSize = std::min(size_t(remainingDataSize), size_t(end - current));
115
+ if (dataSize == 0) {
116
+ state = EXPECTING_FINAL_CR;
117
+ } else {
118
+ emitDataEvent(current, dataSize);
119
+ current += dataSize;
120
+ remainingDataSize -= (unsigned int) dataSize;
121
+ if (remainingDataSize == 0) {
122
+ state = EXPECTING_NON_FINAL_CR;
123
+ }
124
+ }
125
+ break;
126
+
127
+ case EXPECTING_SIZE:
128
+ while (current < end
129
+ && sizeBufferLen < sizeof(sizeBuffer)
130
+ && state == EXPECTING_SIZE)
131
+ {
132
+ if (*current == CR) {
133
+ parseSizeBuffer();
134
+ state = EXPECTING_HEADER_LF;
135
+ } else if (*current == ';') {
136
+ parseSizeBuffer();
137
+ state = EXPECTING_CHUNK_EXTENSION;
138
+ } else if (isDigit(*current)) {
139
+ sizeBuffer[sizeBufferLen] = *current;
140
+ sizeBufferLen++;
141
+ } else {
142
+ setError("Parse error: invalid chunk size character.");
143
+ current--;
144
+ }
145
+ current++;
146
+ }
147
+
148
+ if (sizeBufferLen == sizeof(sizeBuffer) && state == EXPECTING_SIZE) {
149
+ setError("The chunk size header is too large.");
150
+ }
151
+ break;
152
+
153
+ case EXPECTING_CHUNK_EXTENSION:
154
+ needle = (const char *) memchr(current, CR, end - current);
155
+ if (needle == NULL) {
156
+ current = end;
157
+ } else {
158
+ current = needle + 1;
159
+ state = EXPECTING_HEADER_LF;
160
+ }
161
+ break;
162
+
163
+ case EXPECTING_HEADER_LF:
164
+ if (*current == LF) {
165
+ state = EXPECTING_DATA;
166
+ current++;
167
+ } else {
168
+ setError("Parse error: expected a chunk header LF.");
169
+ }
170
+ break;
171
+
172
+ case EXPECTING_NON_FINAL_CR:
173
+ if (*current == CR) {
174
+ state = EXPECTING_NON_FINAL_LF;
175
+ current++;
176
+ } else {
177
+ setError("Parse error: expected a chunk finalizing CR.");
178
+ }
179
+ break;
180
+
181
+ case EXPECTING_NON_FINAL_LF:
182
+ if (*current == LF) {
183
+ reset();
184
+ current++;
185
+ } else {
186
+ setError("Parse error: expected a chunk finalizing LF.");
187
+ }
188
+ break;
189
+
190
+ case EXPECTING_FINAL_CR:
191
+ if (*current == CR) {
192
+ state = EXPECTING_FINAL_LF;
193
+ current++;
194
+ } else {
195
+ setError("Parse error: expected a final CR.");
196
+ }
197
+ break;
198
+
199
+ case EXPECTING_FINAL_LF:
200
+ if (*current == LF) {
201
+ state = DONE;
202
+ current++;
203
+ } else {
204
+ setError("Parse error: expected a final LF.");
205
+ }
206
+ break;
207
+
208
+ default:
209
+ abort();
210
+ }
211
+ }
212
+
213
+ return current - data;
214
+ }
215
+
216
+ bool acceptingInput() const {
217
+ return state != DONE && state != ERROR;
218
+ }
219
+
220
+ bool hasError() const {
221
+ return state == ERROR;
222
+ }
223
+
224
+ const char *getErrorMessage() const {
225
+ return errorMessage;
226
+ }
227
+ };
228
+
229
+
230
+ } // namespace Passenger
231
+
232
+ #endif _PASSENGER_DECHUNKER_H_