passenger 2.1.3 → 2.2.0
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.
- data/DEVELOPERS.TXT +2 -0
- data/INSTALL +3 -1
- data/LICENSE +19 -355
- data/NEWS +3 -0
- data/README +11 -4
- data/Rakefile +435 -236
- data/bin/passenger-config +20 -14
- data/bin/passenger-install-apache2-module +67 -201
- data/bin/passenger-install-nginx-module +477 -0
- data/bin/passenger-make-enterprisey +17 -12
- data/bin/passenger-memory-stats +33 -23
- data/bin/passenger-spawn-server +17 -12
- data/bin/passenger-status +18 -13
- data/bin/passenger-stress-test +17 -12
- data/doc/{Users guide.html → Users guide Apache.html } +79 -61
- data/doc/{Users guide.txt → Users guide Apache.txt } +43 -939
- data/doc/Users guide Nginx.html +2276 -0
- data/doc/Users guide Nginx.txt +776 -0
- data/doc/cxxapi/ApplicationPoolServer_8h-source.html +9 -4
- data/doc/cxxapi/ApplicationPool_8h-source.html +9 -4
- data/doc/cxxapi/Application_8h-source.html +26 -21
- data/doc/cxxapi/Bucket_8h-source.html +54 -44
- data/doc/cxxapi/CachedFileStat_8h-source.html +9 -4
- data/doc/cxxapi/Configuration_8h-source.html +357 -339
- data/doc/cxxapi/DirectoryMapper_8h-source.html +294 -280
- data/doc/cxxapi/DummySpawnManager_8h-source.html +9 -4
- data/doc/cxxapi/Exceptions_8h-source.html +9 -4
- data/doc/cxxapi/FileChecker_8h-source.html +9 -4
- data/doc/cxxapi/Hooks_8h-source.html +50 -40
- data/doc/cxxapi/Logging_8h-source.html +9 -4
- data/doc/cxxapi/MessageChannel_8h-source.html +20 -15
- data/doc/cxxapi/PoolOptions_8h-source.html +10 -5
- data/doc/cxxapi/SpawnManager_8h-source.html +9 -4
- data/doc/cxxapi/StandardApplicationPool_8h-source.html +10 -5
- data/doc/cxxapi/SystemTime_8h-source.html +9 -4
- data/doc/cxxapi/Utils_8h-source.html +242 -214
- data/doc/cxxapi/annotated.html +4 -28
- data/doc/cxxapi/classClient-members.html +4 -4
- data/doc/cxxapi/classClient.html +14 -11
- data/doc/cxxapi/classHooks-members.html +4 -5
- data/doc/cxxapi/classHooks.html +26 -24
- data/doc/cxxapi/classPassenger_1_1Application-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1Application.html +40 -37
- data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +95 -92
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +26 -23
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +17 -17
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +139 -136
- data/doc/cxxapi/classPassenger_1_1BufferedUpload-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1BufferedUpload.html +13 -10
- data/doc/cxxapi/classPassenger_1_1BusyException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1BusyException.html +11 -8
- data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +11 -8
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +4 -5
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +45 -43
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +13 -10
- data/doc/cxxapi/classPassenger_1_1FileChecker-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1FileChecker.html +22 -19
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +12 -9
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1FileSystemException.html +14 -11
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1IOException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1IOException.html +12 -9
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1MessageChannel.html +228 -225
- data/doc/cxxapi/classPassenger_1_1RuntimeException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1RuntimeException.html +11 -8
- data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1SpawnException.html +14 -11
- data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1SpawnManager.html +50 -47
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +73 -70
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1SystemException-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1SystemException.html +17 -14
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.map +1 -1
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.md5 +1 -1
- data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
- data/doc/cxxapi/classPassenger_1_1SystemTime-members.html +4 -4
- data/doc/cxxapi/classPassenger_1_1SystemTime.html +14 -11
- data/doc/cxxapi/classes.html +35 -0
- data/doc/cxxapi/definitions_8h-source.html +9 -4
- data/doc/cxxapi/doxygen.css +311 -303
- data/doc/cxxapi/files.html +9 -18
- data/doc/cxxapi/functions.html +5 -224
- data/doc/cxxapi/functions_func.html +5 -185
- data/doc/cxxapi/functions_type.html +4 -4
- data/doc/cxxapi/functions_vars.html +4 -4
- data/doc/cxxapi/graph_legend.dot +19 -19
- data/doc/cxxapi/graph_legend.html +5 -5
- data/doc/cxxapi/graph_legend.png +0 -0
- data/doc/cxxapi/group__Configuration.html +11 -13
- data/doc/cxxapi/group__Configuration.png +0 -0
- data/doc/cxxapi/group__Core.html +10 -12
- data/doc/cxxapi/group__Core.png +0 -0
- data/doc/cxxapi/group__Exceptions.html +5 -7
- data/doc/cxxapi/group__Hooks.html +5 -7
- data/doc/cxxapi/group__Hooks.png +0 -0
- data/doc/cxxapi/group__Support.html +5 -624
- data/doc/cxxapi/hierarchy.html +6 -6
- data/doc/cxxapi/inherit__graph__0.map +1 -1
- data/doc/cxxapi/inherit__graph__0.md5 +1 -1
- data/doc/cxxapi/inherit__graph__0.png +0 -0
- data/doc/cxxapi/inherit__graph__1.map +1 -1
- data/doc/cxxapi/inherit__graph__1.md5 +1 -1
- data/doc/cxxapi/inherit__graph__1.png +0 -0
- data/doc/cxxapi/inherit__graph__10.map +1 -1
- data/doc/cxxapi/inherit__graph__10.md5 +1 -1
- data/doc/cxxapi/inherit__graph__10.png +0 -0
- data/doc/cxxapi/inherit__graph__11.map +1 -1
- data/doc/cxxapi/inherit__graph__11.md5 +1 -1
- data/doc/cxxapi/inherit__graph__11.png +0 -0
- data/doc/cxxapi/inherit__graph__12.map +1 -1
- data/doc/cxxapi/inherit__graph__12.md5 +1 -1
- data/doc/cxxapi/inherit__graph__12.png +0 -0
- data/doc/cxxapi/inherit__graph__13.map +1 -2
- data/doc/cxxapi/inherit__graph__13.md5 +1 -1
- data/doc/cxxapi/inherit__graph__13.png +0 -0
- data/doc/cxxapi/inherit__graph__14.map +2 -1
- data/doc/cxxapi/inherit__graph__14.md5 +1 -1
- data/doc/cxxapi/inherit__graph__14.png +0 -0
- data/doc/cxxapi/inherit__graph__15.map +1 -1
- data/doc/cxxapi/inherit__graph__15.md5 +1 -1
- data/doc/cxxapi/inherit__graph__15.png +0 -0
- data/doc/cxxapi/inherit__graph__16.map +1 -1
- data/doc/cxxapi/inherit__graph__16.md5 +1 -1
- data/doc/cxxapi/inherit__graph__16.png +0 -0
- data/doc/cxxapi/inherit__graph__17.map +1 -1
- data/doc/cxxapi/inherit__graph__17.md5 +1 -1
- data/doc/cxxapi/inherit__graph__17.png +0 -0
- data/doc/cxxapi/inherit__graph__18.map +1 -1
- data/doc/cxxapi/inherit__graph__18.md5 +1 -1
- data/doc/cxxapi/inherit__graph__18.png +0 -0
- data/doc/cxxapi/inherit__graph__19.map +1 -1
- data/doc/cxxapi/inherit__graph__19.md5 +1 -1
- data/doc/cxxapi/inherit__graph__19.png +0 -0
- data/doc/cxxapi/inherit__graph__2.map +1 -1
- data/doc/cxxapi/inherit__graph__2.md5 +1 -1
- data/doc/cxxapi/inherit__graph__2.png +0 -0
- data/doc/cxxapi/inherit__graph__20.map +2 -2
- data/doc/cxxapi/inherit__graph__20.md5 +1 -1
- data/doc/cxxapi/inherit__graph__20.png +0 -0
- data/doc/cxxapi/inherit__graph__21.map +1 -1
- data/doc/cxxapi/inherit__graph__21.md5 +1 -1
- data/doc/cxxapi/inherit__graph__21.png +0 -0
- data/doc/cxxapi/inherit__graph__3.map +1 -1
- data/doc/cxxapi/inherit__graph__3.md5 +1 -1
- data/doc/cxxapi/inherit__graph__3.png +0 -0
- data/doc/cxxapi/inherit__graph__4.map +1 -1
- data/doc/cxxapi/inherit__graph__4.md5 +1 -1
- data/doc/cxxapi/inherit__graph__4.png +0 -0
- data/doc/cxxapi/inherit__graph__5.map +1 -2
- data/doc/cxxapi/inherit__graph__5.md5 +1 -1
- data/doc/cxxapi/inherit__graph__5.png +0 -0
- data/doc/cxxapi/inherit__graph__6.map +2 -1
- data/doc/cxxapi/inherit__graph__6.md5 +1 -1
- data/doc/cxxapi/inherit__graph__6.png +0 -0
- data/doc/cxxapi/inherit__graph__7.map +1 -1
- data/doc/cxxapi/inherit__graph__7.md5 +1 -1
- data/doc/cxxapi/inherit__graph__7.png +0 -0
- data/doc/cxxapi/inherit__graph__8.map +1 -1
- data/doc/cxxapi/inherit__graph__8.md5 +1 -1
- data/doc/cxxapi/inherit__graph__8.png +0 -0
- data/doc/cxxapi/inherit__graph__9.map +1 -1
- data/doc/cxxapi/inherit__graph__9.md5 +1 -1
- data/doc/cxxapi/inherit__graph__9.png +0 -0
- data/doc/cxxapi/inherits.html +41 -41
- data/doc/cxxapi/main.html +4 -4
- data/doc/cxxapi/modules.html +4 -5
- data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +4 -4
- data/doc/cxxapi/structPassenger_1_1AnythingToString.html +13 -10
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +5 -5
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +16 -13
- data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +4 -4
- data/doc/cxxapi/structPassenger_1_1PoolOptions.html +63 -60
- data/doc/cxxapi/tabs.css +5 -2
- data/doc/cxxapi/tree.html +7 -81
- data/doc/rdoc/classes/ConditionVariable.html +59 -59
- data/doc/rdoc/classes/Exception.html +11 -11
- data/doc/rdoc/classes/GC.html +4 -4
- data/doc/rdoc/classes/IO.html +14 -14
- data/doc/rdoc/classes/PhusionPassenger.html +75 -20
- data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +153 -0
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +125 -130
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +236 -236
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +213 -213
- data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +28 -28
- data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +91 -75
- data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +10 -10
- data/doc/rdoc/classes/PhusionPassenger/Application.html +64 -64
- data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +34 -34
- data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +13 -13
- data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +30 -30
- data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +10 -10
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +136 -136
- data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +24 -24
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +42 -42
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +55 -53
- data/doc/rdoc/classes/PhusionPassenger/Railz.html +1 -1
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +25 -30
- data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +23 -23
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +116 -117
- data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +22 -22
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +118 -124
- data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +10 -10
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +354 -354
- data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +9 -9
- data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +37 -37
- data/doc/rdoc/classes/PlatformInfo.html +282 -261
- data/doc/rdoc/classes/RakeExtensions.html +7 -7
- data/doc/rdoc/classes/Signal.html +26 -26
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +6 -1
- data/doc/rdoc/files/README.html +15 -6
- data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +129 -0
- data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +20 -13
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +31 -1
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +31 -1
- data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +21 -12
- data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +122 -0
- data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +22 -12
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +21 -12
- data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +21 -12
- data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +19 -13
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +27 -21
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +21 -12
- data/doc/rdoc/files/misc/rake/extensions_rb.html +21 -12
- data/doc/rdoc/fr_class_index.html +1 -0
- data/doc/rdoc/fr_file_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +116 -112
- data/doc/users_guide_snippets/analysis_and_system_maintenance_tools.txt +144 -0
- data/doc/users_guide_snippets/appendix_a_about.txt +13 -0
- data/doc/users_guide_snippets/appendix_b_terminology.txt +63 -0
- data/doc/users_guide_snippets/appendix_c_spawning_methods.txt +304 -0
- data/doc/users_guide_snippets/global_queueing_explained.txt +78 -0
- data/doc/users_guide_snippets/rackup_specifications.txt +75 -0
- data/doc/users_guide_snippets/rails_spawn_method.txt +48 -0
- data/doc/users_guide_snippets/tips.txt +173 -0
- data/ext/apache2/Bucket.cpp +17 -12
- data/ext/apache2/Bucket.h +17 -12
- data/ext/apache2/Configuration.cpp +17 -12
- data/ext/apache2/Configuration.h +27 -14
- data/ext/apache2/DirectoryMapper.h +21 -12
- data/ext/apache2/Hooks.cpp +67 -21
- data/ext/apache2/Hooks.h +17 -12
- data/ext/apache2/mod_passenger.c +17 -12
- data/ext/{apache2 → common}/Application.h +19 -14
- data/ext/{apache2 → common}/ApplicationPool.h +17 -12
- data/ext/{apache2 → common}/ApplicationPoolServer.h +18 -72
- data/ext/{apache2 → common}/ApplicationPoolServerExecutable.cpp +45 -104
- data/ext/common/ApplicationPoolStatusReporter.h +212 -0
- data/ext/{apache2 → common}/CachedFileStat.cpp +17 -12
- data/ext/{apache2 → common}/CachedFileStat.h +17 -12
- data/ext/{apache2 → common}/DummySpawnManager.h +17 -12
- data/ext/{apache2 → common}/Exceptions.h +17 -12
- data/ext/{apache2 → common}/FileChecker.h +17 -12
- data/ext/common/Logging.cpp +65 -0
- data/ext/{apache2 → common}/Logging.h +17 -12
- data/ext/{apache2 → common}/MessageChannel.h +17 -12
- data/ext/{apache2 → common}/PoolOptions.h +17 -12
- data/ext/{apache2 → common}/SpawnManager.h +17 -12
- data/ext/{apache2 → common}/StandardApplicationPool.h +17 -12
- data/ext/common/StaticString.h +147 -0
- data/ext/common/SystemTime.cpp +33 -0
- data/ext/{apache2 → common}/SystemTime.h +17 -12
- data/ext/{apache2 → common}/Utils.cpp +69 -12
- data/ext/{apache2 → common}/Utils.h +41 -12
- data/ext/nginx/Configuration.c +1091 -0
- data/ext/nginx/Configuration.h +71 -0
- data/ext/nginx/ContentHandler.c +1154 -0
- data/ext/nginx/ContentHandler.h +64 -0
- data/ext/nginx/HelperServer.cpp +857 -0
- data/ext/nginx/HttpStatusExtractor.h +161 -0
- data/ext/nginx/ScgiRequestParser.h +317 -0
- data/ext/nginx/StaticContentHandler.c +222 -0
- data/ext/nginx/StaticContentHandler.h +37 -0
- data/ext/nginx/config +41 -0
- data/ext/nginx/ngx_http_passenger_module.c +572 -0
- data/ext/nginx/ngx_http_passenger_module.h +72 -0
- data/ext/oxt/backtrace.cpp +8 -1
- data/ext/oxt/system_calls.cpp +40 -0
- data/ext/oxt/system_calls.hpp +14 -7
- data/ext/phusion_passenger/extconf.rb +17 -12
- data/ext/phusion_passenger/native_support.c +19 -12
- data/lib/phusion_passenger/abstract_installer.rb +196 -0
- data/lib/phusion_passenger/abstract_request_handler.rb +19 -24
- data/lib/phusion_passenger/abstract_server.rb +17 -12
- data/lib/phusion_passenger/abstract_server_collection.rb +17 -12
- data/lib/phusion_passenger/admin_tools.rb +23 -0
- data/lib/phusion_passenger/admin_tools/control_process.rb +39 -13
- data/lib/phusion_passenger/application.rb +17 -12
- data/lib/phusion_passenger/console_text_template.rb +17 -12
- data/lib/phusion_passenger/constants.rb +22 -11
- data/lib/phusion_passenger/dependencies.rb +47 -12
- data/lib/phusion_passenger/events.rb +17 -12
- data/lib/phusion_passenger/exceptions.rb +17 -12
- data/lib/phusion_passenger/html_template.rb +17 -12
- data/lib/phusion_passenger/message_channel.rb +17 -12
- data/lib/phusion_passenger/packaging.rb +39 -0
- data/lib/phusion_passenger/platform_info.rb +48 -22
- data/lib/phusion_passenger/rack/application_spawner.rb +22 -11
- data/lib/phusion_passenger/rack/request_handler.rb +21 -12
- data/lib/phusion_passenger/railz/application_spawner.rb +23 -23
- data/lib/phusion_passenger/railz/framework_spawner.rb +18 -14
- data/lib/phusion_passenger/railz/request_handler.rb +18 -11
- data/lib/phusion_passenger/simple_benchmarking.rb +17 -12
- data/lib/phusion_passenger/spawn_manager.rb +17 -20
- data/lib/phusion_passenger/templates/{apache_must_be_compiled_with_compatible_mpm.txt.erb → apache2/apache_must_be_compiled_with_compatible_mpm.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{apache2_config_snippets.txt.erb → apache2/config_snippets.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{deployment_example.txt.erb → apache2/deployment_example.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{no_write_permission_to_passenger_root.txt.erb → apache2/no_write_permission_to_passenger_root.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{possible_solutions_for_compilation_and_installation_problems.txt.erb → apache2/possible_solutions_for_compilation_and_installation_problems.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{run_installer_as_root.txt.erb → apache2/run_installer_as_root.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/{welcome.txt.erb → apache2/welcome.txt.erb} +0 -0
- data/lib/phusion_passenger/templates/nginx/ask_for_extra_configure_flags.txt.erb +8 -0
- data/lib/phusion_passenger/templates/nginx/cannot_write_to_dir.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/config_snippets.txt.erb +17 -0
- data/lib/phusion_passenger/templates/nginx/config_snippets_inserted.txt.erb +20 -0
- data/lib/phusion_passenger/templates/nginx/confirm_extra_configure_flags.txt.erb +5 -0
- data/lib/phusion_passenger/templates/nginx/deployment_example.txt.erb +22 -0
- data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_downloaded.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_extracted.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/possible_solutions_for_compilation_and_installation_problems.txt.erb +11 -0
- data/lib/phusion_passenger/templates/nginx/possible_solutions_for_download_and_extraction_problems.txt.erb +20 -0
- data/lib/phusion_passenger/templates/nginx/query_download_and_install.txt.erb +21 -0
- data/lib/phusion_passenger/templates/nginx/run_installer_as_root.txt.erb +8 -0
- data/lib/phusion_passenger/templates/nginx/welcome.txt.erb +15 -0
- data/lib/phusion_passenger/utils.rb +20 -15
- data/lib/phusion_passenger/wsgi/application_spawner.rb +18 -11
- data/lib/phusion_passenger/wsgi/request_handler.py +23 -0
- data/misc/copy_boost_headers.rb +23 -0
- data/misc/find_owner_pipe_leaks.rb +18 -11
- data/misc/rake/cplusplus.rb +18 -11
- data/misc/rake/extensions.rb +21 -14
- data/misc/render_error_pages.rb +18 -11
- data/test/ApplicationPoolServerTest.cpp +1 -3
- data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +1 -1
- data/test/CxxTestMain.cpp +19 -3
- data/test/HttpStatusExtractorTest.cpp +181 -0
- data/test/ScgiRequestParserTest.cpp +337 -0
- data/test/StaticStringTest.cpp +51 -0
- data/test/UtilsTest.cpp +32 -0
- data/test/config.yml.example +5 -0
- data/test/{integration_tests.rb → integration_tests/apache2_tests.rb} +7 -299
- data/test/integration_tests/hello_world_rack_spec.rb +36 -0
- data/test/integration_tests/hello_world_wsgi_spec.rb +41 -0
- data/test/integration_tests/mycook_spec.rb +192 -0
- data/test/integration_tests/nginx_tests.rb +98 -0
- data/test/ruby/rack/application_spawner_spec.rb +40 -0
- data/test/stub/nginx/koi-utf +109 -0
- data/test/stub/nginx/koi-win +103 -0
- data/test/stub/nginx/mime.types +70 -0
- data/test/stub/nginx/nginx.conf.erb +57 -0
- data/test/stub/nginx/win-utf +126 -0
- data/test/stub/rails_apps/mycook/app/controllers/uploads_controller.rb +4 -0
- data/test/stub/rails_apps/mycook/config/routes.rb +1 -1
- data/test/stub/wsgi/passenger_wsgi.pyc +0 -0
- data/test/support/Support.h +40 -0
- data/test/support/nginx_controller.rb +98 -0
- data/test/support/test_helper.rb +79 -0
- metadata +1091 -1028
- data/benchmark/DummyRequestHandler.cpp +0 -101
- data/ext/apache2/Logging.cpp +0 -60
- data/ext/apache2/SystemTime.cpp +0 -28
@@ -0,0 +1,161 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - http://www.modrails.com/
|
3
|
+
* Copyright (c) 2009 Phusion
|
4
|
+
*
|
5
|
+
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
*
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
|
26
|
+
#include <string>
|
27
|
+
|
28
|
+
namespace Passenger {
|
29
|
+
|
30
|
+
using namespace std;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Utility class for extracting the HTTP status value from an HTTP response.
|
34
|
+
*
|
35
|
+
* This class is used for generating a proper HTTP response. The response data
|
36
|
+
* that Passenger backend processes generate are like CGI responses, and do not
|
37
|
+
* include an initial "HTTP/1.1 [status here]" line, so this class used to
|
38
|
+
* extract the status from the response in order to generate a proper initial
|
39
|
+
* HTTP response line.
|
40
|
+
*
|
41
|
+
* This class is supposed to be used as follows:
|
42
|
+
* - Keep feeding HTTP response data until feed() returns true. feed()
|
43
|
+
* buffers all fed data until it is able to extract the HTTP status.
|
44
|
+
* - Call getStatusLine() to retrieve the status line, and use this to generate
|
45
|
+
* an HTTP response line.
|
46
|
+
* - Call getBuffer() to retrieve all fed data so far. This data can be sent to
|
47
|
+
* the HTTP client.
|
48
|
+
*
|
49
|
+
* @note
|
50
|
+
* When the API documentation for this class refers to "\r\n", we actually
|
51
|
+
* mean "\x0D\x0A" (the HTTP line termination string). "\r\n" is only written
|
52
|
+
* out of convenience.
|
53
|
+
*/
|
54
|
+
class HttpStatusExtractor {
|
55
|
+
private:
|
56
|
+
static const char CR = '\x0D';
|
57
|
+
static const char LF = '\x0A';
|
58
|
+
|
59
|
+
string buffer;
|
60
|
+
unsigned int searchStart;
|
61
|
+
bool fullHeaderReceived;
|
62
|
+
string statusLine;
|
63
|
+
|
64
|
+
bool extractStatusLine() {
|
65
|
+
static const char statusHeaderName[] = "Status: ";
|
66
|
+
string::size_type start_pos, newline_pos;
|
67
|
+
|
68
|
+
if (buffer.size() > sizeof(statusHeaderName) - 1
|
69
|
+
&& memcmp(buffer.c_str(), statusHeaderName, sizeof(statusHeaderName) - 1) == 0) {
|
70
|
+
// Status line starts at beginning of the header.
|
71
|
+
start_pos = sizeof(statusHeaderName) - 1;
|
72
|
+
newline_pos = buffer.find("\x0D\x0A", 0, 2) + 2;
|
73
|
+
} else {
|
74
|
+
// Status line is not at the beginning of the header.
|
75
|
+
// Look for it.
|
76
|
+
start_pos = buffer.find("\x0D\x0AStatus: ");
|
77
|
+
if (start_pos != string::npos) {
|
78
|
+
start_pos += 2 + sizeof(statusHeaderName) - 1;
|
79
|
+
newline_pos = buffer.find("\x0D\x0A", start_pos, 2) + 2;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
if (start_pos != string::npos) {
|
83
|
+
// Status line has been found. Extract it.
|
84
|
+
statusLine = buffer.substr(start_pos, newline_pos - start_pos);
|
85
|
+
return true;
|
86
|
+
} else {
|
87
|
+
// Status line is not found. Do not change default
|
88
|
+
// status line value.
|
89
|
+
return false;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
public:
|
94
|
+
HttpStatusExtractor() {
|
95
|
+
searchStart = 0;
|
96
|
+
fullHeaderReceived = false;
|
97
|
+
statusLine = "200 OK\r\n";
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Feed HTTP response data to this HttpStatusExtractor.
|
102
|
+
*
|
103
|
+
* One is to keep feeding data until this method returns true.
|
104
|
+
* When a sufficient amount of data has been fed, this method will
|
105
|
+
* extract the status line from the data that has been fed so far,
|
106
|
+
* and return true.
|
107
|
+
*
|
108
|
+
* Do not call this method again once it has returned true.
|
109
|
+
*
|
110
|
+
* It is safe to feed excess data. That is, it is safe if the 'data'
|
111
|
+
* argument contains a part of the HTTP response body.
|
112
|
+
* HttpStatusExtractor will only look for the status line in the HTTP
|
113
|
+
* response header, not in the HTTP response body. All fed data is
|
114
|
+
* buffered and will be available via getBuffer(), so no data will be
|
115
|
+
* lost.
|
116
|
+
*
|
117
|
+
* @return Whether the HTTP status has been extracted yet.
|
118
|
+
* @pre feed() did not previously return true.
|
119
|
+
* @pre data != NULL
|
120
|
+
* @pre size > 0
|
121
|
+
*/
|
122
|
+
bool feed(const char *data, unsigned int size) {
|
123
|
+
if (fullHeaderReceived) {
|
124
|
+
return true;
|
125
|
+
}
|
126
|
+
buffer.append(data, size);
|
127
|
+
for (; buffer.size() >= 3 && searchStart < buffer.size() - 3; searchStart++) {
|
128
|
+
if (buffer[searchStart] == CR &&
|
129
|
+
buffer[searchStart + 1] == LF &&
|
130
|
+
buffer[searchStart + 2] == CR &&
|
131
|
+
buffer[searchStart + 3] == LF) {
|
132
|
+
fullHeaderReceived = true;
|
133
|
+
extractStatusLine();
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
return false;
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Returns the HTTP status line that has been determined.
|
142
|
+
*
|
143
|
+
* The default value is "200 OK\r\n", which is returned if the HTTP
|
144
|
+
* response data that has been fed so far does not include a status
|
145
|
+
* line.
|
146
|
+
*
|
147
|
+
* @note The return value includes a trailing CRLF, e.g. "404 Not Found\r\n".
|
148
|
+
*/
|
149
|
+
string getStatusLine() const {
|
150
|
+
return statusLine;
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Get the data that has been fed so far.
|
155
|
+
*/
|
156
|
+
string getBuffer() const {
|
157
|
+
return buffer;
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
} // namespace Passenger
|
@@ -0,0 +1,317 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - http://www.modrails.com/
|
3
|
+
* Copyright (c) 2009 Phusion
|
4
|
+
*
|
5
|
+
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
*
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
12
|
+
* furnished to do so, subject to the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
15
|
+
* all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
* THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
|
26
|
+
#include <string>
|
27
|
+
#include <map>
|
28
|
+
|
29
|
+
#include "StaticString.h"
|
30
|
+
|
31
|
+
using namespace std;
|
32
|
+
|
33
|
+
namespace Passenger {
|
34
|
+
|
35
|
+
/**
|
36
|
+
* A parser for SCGI requests. It parses the request header and ignores the
|
37
|
+
* body data.
|
38
|
+
*
|
39
|
+
* You can use it by constructing a parser object, then feeding data to the
|
40
|
+
* parser until it has reached a final state.
|
41
|
+
*
|
42
|
+
* Example:
|
43
|
+
* @code
|
44
|
+
* ScgiRequestParser parser;
|
45
|
+
* char buf[1024 * 16];
|
46
|
+
* ssize_t size;
|
47
|
+
* unsigned in bytesAccepted;
|
48
|
+
*
|
49
|
+
* do {
|
50
|
+
* size = read(fd, buf, sizeof(buf));
|
51
|
+
* bytesAccepted = parser.feed(buf, size);
|
52
|
+
* } while (parser.acceptingInput());
|
53
|
+
* // Parser is done when its return value isn't equal to the input size.
|
54
|
+
*
|
55
|
+
* // Check whether a parse error occured.
|
56
|
+
* if (parser.getState() == ScgiRequestParser::ERROR) {
|
57
|
+
* bailOut();
|
58
|
+
* } else {
|
59
|
+
* // All good! Do something with the SCGI header that the parser parsed.
|
60
|
+
* processHeader(parser.getHeaderData());
|
61
|
+
*
|
62
|
+
* // If the last buffer passed to the parser also contains body data,
|
63
|
+
* // then the body data starts at 'buf + bytesAccepted'.
|
64
|
+
* if (bytesAccepted < size) {
|
65
|
+
* processBody(buf + bytesAccepted);
|
66
|
+
* }
|
67
|
+
* while (!end_of_file(fd)) {
|
68
|
+
* ... read(...) ...
|
69
|
+
* processBody(...);
|
70
|
+
* }
|
71
|
+
* }
|
72
|
+
* @endcode
|
73
|
+
*
|
74
|
+
* Parser properties:
|
75
|
+
* - A parser object can only process a single SCGI request. You must discard
|
76
|
+
* the existing parser object and create a new one if you want to process
|
77
|
+
* another SCGI request.
|
78
|
+
* - This parser checks whether the header netstring is valid. It will enter
|
79
|
+
* the error state if it encounters a parse error.
|
80
|
+
* - However, this parser does not perform any validation of the actual header
|
81
|
+
* contents. For example, it doesn't check that CONTENT_LENGTH is the first
|
82
|
+
* header, or that the SCGI header is present.
|
83
|
+
*/
|
84
|
+
class ScgiRequestParser {
|
85
|
+
public:
|
86
|
+
enum State {
|
87
|
+
READING_LENGTH_STRING,
|
88
|
+
READING_HEADER_DATA,
|
89
|
+
EXPECTING_COMMA,
|
90
|
+
DONE,
|
91
|
+
ERROR
|
92
|
+
};
|
93
|
+
|
94
|
+
private:
|
95
|
+
State state;
|
96
|
+
char lengthStringBuffer[sizeof("4294967296")];
|
97
|
+
unsigned int lengthStringBufferSize;
|
98
|
+
unsigned long headerSize;
|
99
|
+
string headerBuffer;
|
100
|
+
map<StaticString, StaticString> headers;
|
101
|
+
|
102
|
+
static inline bool isDigit(char byte) {
|
103
|
+
return byte >= '0' && byte <= '9';
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Parse the given header data into key-value pairs.
|
108
|
+
*/
|
109
|
+
bool parseHeaderData(const string &data, map<StaticString, StaticString> &output) {
|
110
|
+
bool isName = true; // Whether we're currently expecting a name or a value.
|
111
|
+
const char *startOfString, *current, *end;
|
112
|
+
StaticString key, value;
|
113
|
+
|
114
|
+
if (data.size() == 0) {
|
115
|
+
return true;
|
116
|
+
}
|
117
|
+
|
118
|
+
startOfString = data.c_str();
|
119
|
+
end = data.c_str() + data.size();
|
120
|
+
|
121
|
+
if (*(end - 1) != '\0') {
|
122
|
+
return false;
|
123
|
+
}
|
124
|
+
|
125
|
+
for (current = data.c_str(); current != end; current++) {
|
126
|
+
if (isName && *current == '\0') {
|
127
|
+
key = StaticString(startOfString, current - startOfString);
|
128
|
+
startOfString = current + 1;
|
129
|
+
isName = false;
|
130
|
+
} else if (!isName && *current == '\0') {
|
131
|
+
value = StaticString(startOfString, current - startOfString);
|
132
|
+
startOfString = current + 1;
|
133
|
+
isName = true;
|
134
|
+
|
135
|
+
output[key] = value;
|
136
|
+
key = StaticString();
|
137
|
+
value = StaticString();
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
return isName;
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Process the given data, which contains header data and possibly
|
146
|
+
* some body data as well.
|
147
|
+
*/
|
148
|
+
unsigned int readHeaderData(const char *data, unsigned int size) {
|
149
|
+
unsigned int bytesToRead;
|
150
|
+
|
151
|
+
// Calculate how many bytes of header data is left to be read.
|
152
|
+
// Do not read past the header data.
|
153
|
+
if (size < headerSize - headerBuffer.size()) {
|
154
|
+
bytesToRead = size;
|
155
|
+
} else {
|
156
|
+
bytesToRead = headerSize - headerBuffer.size();
|
157
|
+
}
|
158
|
+
// Append the newly received header data to the header data buffer.
|
159
|
+
headerBuffer.append(data, bytesToRead);
|
160
|
+
|
161
|
+
if (headerBuffer.size() == headerSize) {
|
162
|
+
// We've received all header data. Now attempt to parse this.
|
163
|
+
if (bytesToRead < size) {
|
164
|
+
if (data[bytesToRead] == ',') {
|
165
|
+
if (parseHeaderData(headerBuffer, headers)) {
|
166
|
+
state = DONE;
|
167
|
+
return bytesToRead + 1;
|
168
|
+
} else {
|
169
|
+
state = ERROR;
|
170
|
+
return bytesToRead;
|
171
|
+
}
|
172
|
+
} else {
|
173
|
+
state = ERROR;
|
174
|
+
return bytesToRead;
|
175
|
+
}
|
176
|
+
} else {
|
177
|
+
if (parseHeaderData(headerBuffer, headers)) {
|
178
|
+
state = EXPECTING_COMMA;
|
179
|
+
} else {
|
180
|
+
state = ERROR;
|
181
|
+
}
|
182
|
+
return bytesToRead;
|
183
|
+
}
|
184
|
+
} else {
|
185
|
+
// Not all header data has been received yet.
|
186
|
+
return bytesToRead;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
public:
|
191
|
+
/**
|
192
|
+
* Create a new ScgiRequestParser, ready to parse a request.
|
193
|
+
*/
|
194
|
+
ScgiRequestParser() {
|
195
|
+
state = READING_LENGTH_STRING;
|
196
|
+
lengthStringBufferSize = 0;
|
197
|
+
headerSize = 0;
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Feed SCGI request data to the parser.
|
202
|
+
*
|
203
|
+
* @param data The data to feed.
|
204
|
+
* @param size The size of the data, in bytes.
|
205
|
+
* @return The number of recognized SCGI header bytes. If this value
|
206
|
+
* equals 'size', then it means all data in 'data' is part of
|
207
|
+
* the SCGI header. If this value is less than size, then it
|
208
|
+
* means only some data in 'data' is part of the SCGI header,
|
209
|
+
* and the remaining 'size - result' bytes are part of the
|
210
|
+
* request body.
|
211
|
+
* @pre size > 0
|
212
|
+
* @post result <= size
|
213
|
+
* @post if result <= size: getState() == DONE || getState() == ERROR
|
214
|
+
*/
|
215
|
+
unsigned int feed(const char *data, unsigned int size) {
|
216
|
+
unsigned int i;
|
217
|
+
|
218
|
+
switch (state) {
|
219
|
+
case READING_LENGTH_STRING:
|
220
|
+
// Keep processing length string data...
|
221
|
+
for (i = 0; i < size; i++) {
|
222
|
+
char byte = data[i];
|
223
|
+
|
224
|
+
if (lengthStringBufferSize == sizeof(lengthStringBuffer) - 1) {
|
225
|
+
// ...and abort if the length string is too long.
|
226
|
+
state = ERROR;
|
227
|
+
return i;
|
228
|
+
} else if (!isDigit(byte)) {
|
229
|
+
if (byte == ':') {
|
230
|
+
// ...until the end of the length string has been reached.
|
231
|
+
state = READING_HEADER_DATA;
|
232
|
+
lengthStringBuffer[lengthStringBufferSize] = '\0';
|
233
|
+
headerSize = atol(lengthStringBuffer);
|
234
|
+
headerBuffer.reserve(headerSize);
|
235
|
+
// From here on, process the rest of the data that we've
|
236
|
+
// received, as header data.
|
237
|
+
return readHeaderData(data + i + 1, size - i - 1) + i + 1;
|
238
|
+
} else {
|
239
|
+
// ...until we encounter a parse error.
|
240
|
+
state = ERROR;
|
241
|
+
return i;
|
242
|
+
}
|
243
|
+
} else {
|
244
|
+
lengthStringBuffer[lengthStringBufferSize] = byte;
|
245
|
+
lengthStringBufferSize++;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
return i;
|
249
|
+
|
250
|
+
case READING_HEADER_DATA:
|
251
|
+
return readHeaderData(data, size);
|
252
|
+
|
253
|
+
case EXPECTING_COMMA:
|
254
|
+
if (data[0] == ',') {
|
255
|
+
state = DONE;
|
256
|
+
return 1;
|
257
|
+
} else {
|
258
|
+
state = ERROR;
|
259
|
+
return 0;
|
260
|
+
}
|
261
|
+
|
262
|
+
default:
|
263
|
+
return 0;
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
/**
|
268
|
+
* Get the raw header data that has been processed so far.
|
269
|
+
*/
|
270
|
+
string getHeaderData() const {
|
271
|
+
return headerBuffer;
|
272
|
+
}
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Get the value of the header with the given name.
|
276
|
+
* Lookup is case-sensitive.
|
277
|
+
*
|
278
|
+
* Returns the empty string if there is no such header.
|
279
|
+
*
|
280
|
+
* @pre getState() == DONE
|
281
|
+
*/
|
282
|
+
StaticString getHeader(const StaticString &name) const {
|
283
|
+
map<StaticString, StaticString>::const_iterator it(headers.find(name));
|
284
|
+
if (it == headers.end()) {
|
285
|
+
return "";
|
286
|
+
} else {
|
287
|
+
return it->second;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Checks whether there is a header with the given name.
|
293
|
+
* Lookup is case-sensitive.
|
294
|
+
*
|
295
|
+
* @pre getState() == DONE
|
296
|
+
*/
|
297
|
+
bool hasHeader(const StaticString &name) const {
|
298
|
+
return headers.find(name) != headers.end();
|
299
|
+
}
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Get the parser's current state.
|
303
|
+
*/
|
304
|
+
State getState() const {
|
305
|
+
return state;
|
306
|
+
}
|
307
|
+
|
308
|
+
/**
|
309
|
+
* Checks whether this parser is still capable of accepting input (that
|
310
|
+
* is, that this parser is not in a final state).
|
311
|
+
*/
|
312
|
+
bool acceptingInput() const {
|
313
|
+
return state != DONE && state != ERROR;
|
314
|
+
}
|
315
|
+
};
|
316
|
+
|
317
|
+
} // namespace Passenger
|