mongrel 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -0
- data/CHANGELOG +2 -0
- data/Manifest +68 -0
- data/bin/mongrel_rails +55 -22
- data/examples/camping/README +3 -0
- data/examples/httpd.conf +474 -0
- data/examples/mime.yaml +3 -0
- data/examples/mongrel.conf +9 -0
- data/examples/monitrc +57 -0
- data/ext/http11/http11.c +25 -12
- data/ext/http11/http11_parser.c +456 -331
- data/ext/http11/http11_parser.h +1 -0
- data/ext/http11/http11_parser.java.rl +170 -0
- data/ext/http11/http11_parser.rl +8 -48
- data/ext/http11/http11_parser_common.rl +54 -0
- data/ext/http11/tst.h +2 -2
- data/ext/http11/tst_cleanup.c +0 -1
- data/ext/http11/tst_insert.c +29 -3
- data/ext/http11/tst_search.c +60 -55
- data/lib/mongrel.rb +68 -53
- data/lib/mongrel/cgi.rb +3 -3
- data/lib/mongrel/command.rb +1 -1
- data/lib/mongrel/configurator.rb +41 -31
- data/lib/mongrel/debug.rb +2 -5
- data/lib/mongrel/handlers.rb +23 -9
- data/lib/mongrel/mime_types.yml +2 -1
- data/lib/mongrel/rails.rb +7 -15
- data/mongrel-public_cert.pem +20 -0
- data/mongrel.gemspec +211 -0
- data/test/jruby_socket.rb +39 -0
- data/test/test_cgi_wrapper.rb +26 -0
- data/test/test_command.rb +1 -4
- data/test/test_conditional.rb +6 -18
- data/test/test_configurator.rb +5 -8
- data/test/test_debug.rb +3 -11
- data/test/test_handlers.rb +8 -10
- data/test/test_http11.rb +24 -5
- data/test/test_redirect_handler.rb +2 -6
- data/test/test_request_progress.rb +5 -9
- data/test/test_response.rb +24 -3
- data/test/test_stats.rb +1 -3
- data/test/test_uriclassifier.rb +170 -81
- data/test/test_ws.rb +25 -24
- data/test/testhelp.rb +26 -3
- data/tools/trickletest.rb +2 -2
- metadata +138 -333
- metadata.gz.sig +0 -0
- data/Rakefile +0 -117
- data/doc/rdoc/classes/IO.html +0 -170
- data/doc/rdoc/classes/IO.src/M000003.html +0 -19
- data/doc/rdoc/classes/IO.src/M000004.html +0 -19
- data/doc/rdoc/classes/Kernel.html +0 -159
- data/doc/rdoc/classes/Kernel.src/M000012.html +0 -19
- data/doc/rdoc/classes/Kernel.src/M000013.html +0 -23
- data/doc/rdoc/classes/Mongrel.html +0 -204
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +0 -404
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000115.html +0 -25
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000116.html +0 -47
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000117.html +0 -34
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000118.html +0 -32
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000119.html +0 -25
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000120.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000121.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000122.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000123.html +0 -19
- data/doc/rdoc/classes/Mongrel/Camping.html +0 -177
- data/doc/rdoc/classes/Mongrel/Camping.src/M000041.html +0 -22
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +0 -184
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000042.html +0 -20
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000043.html +0 -58
- data/doc/rdoc/classes/Mongrel/Command.html +0 -132
- data/doc/rdoc/classes/Mongrel/Command/Base.html +0 -384
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000018.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000019.html +0 -42
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000020.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000021.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000022.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000023.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +0 -22
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Registry.html +0 -192
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000031.html +0 -20
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000032.html +0 -29
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000033.html +0 -58
- data/doc/rdoc/classes/Mongrel/Configurator.html +0 -716
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000093.html +0 -27
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000094.html +0 -31
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000095.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000096.html +0 -21
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000097.html +0 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000098.html +0 -23
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +0 -38
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000101.html +0 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +0 -39
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +0 -33
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +0 -24
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +0 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +0 -22
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +0 -22
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +0 -34
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +0 -36
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +0 -18
- data/doc/rdoc/classes/Mongrel/Const.html +0 -337
- data/doc/rdoc/classes/Mongrel/DeflateFilter.html +0 -188
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000124.html +0 -19
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000125.html +0 -23
- data/doc/rdoc/classes/Mongrel/DirHandler.html +0 -303
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000051.html +0 -21
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000052.html +0 -42
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000053.html +0 -38
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000054.html +0 -65
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000055.html +0 -39
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +0 -18
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +0 -171
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000126.html +0 -18
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000127.html +0 -18
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +0 -190
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000066.html +0 -21
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000067.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +0 -215
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000072.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000073.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000074.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +0 -210
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000014.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000015.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000016.html +0 -19
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000017.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpParams.html +0 -131
- data/doc/rdoc/classes/Mongrel/HttpParser.html +0 -278
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000044.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000045.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000046.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000047.html +0 -59
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000048.html +0 -27
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000049.html +0 -27
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000050.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpParserError.html +0 -111
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +0 -284
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000133.html +0 -50
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000134.html +0 -41
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000135.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000136.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000137.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000138.html +0 -32
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +0 -443
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +0 -25
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +0 -26
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +0 -31
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000085.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpServer.html +0 -402
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000057.html +0 -25
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000058.html +0 -100
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000059.html +0 -32
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000060.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000061.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +0 -65
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +0 -34
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +0 -22
- data/doc/rdoc/classes/Mongrel/Rails.html +0 -112
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +0 -225
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000034.html +0 -37
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000035.html +0 -25
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000036.html +0 -26
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +0 -263
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000037.html +0 -23
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000038.html +0 -56
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000039.html +0 -20
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000040.html +0 -25
- data/doc/rdoc/classes/Mongrel/RedirectHandler.html +0 -187
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000131.html +0 -22
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000132.html +0 -27
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +0 -211
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000128.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000129.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000130.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.html +0 -309
- data/doc/rdoc/classes/Mongrel/Stats.src/M000139.html +0 -19
- data/doc/rdoc/classes/Mongrel/Stats.src/M000140.html +0 -23
- data/doc/rdoc/classes/Mongrel/Stats.src/M000141.html +0 -26
- data/doc/rdoc/classes/Mongrel/Stats.src/M000142.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000143.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000144.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000145.html +0 -23
- data/doc/rdoc/classes/Mongrel/Stats.src/M000146.html +0 -20
- data/doc/rdoc/classes/Mongrel/StatusHandler.html +0 -194
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000068.html +0 -18
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000069.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000070.html +0 -42
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +0 -20
- data/doc/rdoc/classes/Mongrel/StopServer.html +0 -117
- data/doc/rdoc/classes/Mongrel/TimeoutError.html +0 -117
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +0 -317
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000087.html +0 -18
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000088.html +0 -18
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html +0 -39
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000090.html +0 -51
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000091.html +0 -36
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +0 -83
- data/doc/rdoc/classes/MongrelDbg.html +0 -209
- data/doc/rdoc/classes/MongrelDbg.src/M000007.html +0 -24
- data/doc/rdoc/classes/MongrelDbg.src/M000008.html +0 -20
- data/doc/rdoc/classes/MongrelDbg.src/M000009.html +0 -22
- data/doc/rdoc/classes/MongrelDbg.src/M000010.html +0 -21
- data/doc/rdoc/classes/MongrelDbg.src/M000011.html +0 -18
- data/doc/rdoc/classes/Mutex.html +0 -158
- data/doc/rdoc/classes/Mutex.src/M000001.html +0 -24
- data/doc/rdoc/classes/Mutex.src/M000002.html +0 -32
- data/doc/rdoc/classes/RequestLog.html +0 -115
- data/doc/rdoc/classes/RequestLog/Access.html +0 -151
- data/doc/rdoc/classes/RequestLog/Access.src/M000147.html +0 -19
- data/doc/rdoc/classes/RequestLog/Files.html +0 -144
- data/doc/rdoc/classes/RequestLog/Files.src/M000148.html +0 -19
- data/doc/rdoc/classes/RequestLog/Objects.html +0 -150
- data/doc/rdoc/classes/RequestLog/Objects.src/M000150.html +0 -51
- data/doc/rdoc/classes/RequestLog/Params.html +0 -144
- data/doc/rdoc/classes/RequestLog/Params.src/M000151.html +0 -19
- data/doc/rdoc/classes/RequestLog/Threads.html +0 -144
- data/doc/rdoc/classes/RequestLog/Threads.src/M000149.html +0 -34
- data/doc/rdoc/classes/TCPServer.html +0 -173
- data/doc/rdoc/classes/TCPServer.src/M000005.html +0 -19
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -168
- data/doc/rdoc/files/LICENSE.html +0 -168
- data/doc/rdoc/files/README.html +0 -213
- data/doc/rdoc/files/ext/http11/http11_c.html +0 -101
- data/doc/rdoc/files/lib/mongrel/camping_rb.html +0 -120
- data/doc/rdoc/files/lib/mongrel/cgi_rb.html +0 -120
- data/doc/rdoc/files/lib/mongrel/command_rb.html +0 -123
- data/doc/rdoc/files/lib/mongrel/configurator_rb.html +0 -111
- data/doc/rdoc/files/lib/mongrel/debug_rb.html +0 -122
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +0 -122
- data/doc/rdoc/files/lib/mongrel/init_rb.html +0 -121
- data/doc/rdoc/files/lib/mongrel/rails_rb.html +0 -123
- data/doc/rdoc/files/lib/mongrel/stats_rb.html +0 -113
- data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +0 -113
- data/doc/rdoc/files/lib/mongrel_rb.html +0 -135
- data/doc/rdoc/files/lib/mutex_fix_rb.html +0 -108
- data/doc/rdoc/fr_class_index.html +0 -68
- data/doc/rdoc/fr_file_index.html +0 -42
- data/doc/rdoc/fr_method_index.html +0 -177
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/tools/rakehelp.rb +0 -117
data/lib/mongrel/debug.rb
CHANGED
@@ -7,17 +7,14 @@
|
|
7
7
|
require 'logger'
|
8
8
|
require 'set'
|
9
9
|
require 'socket'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
$mongrel_debugging=true
|
10
|
+
require 'fileutils'
|
14
11
|
|
15
12
|
module MongrelDbg
|
16
13
|
SETTINGS = { :tracing => {}}
|
17
14
|
LOGGING = { }
|
18
15
|
|
19
16
|
def MongrelDbg::configure(log_dir = File.join("log","mongrel_debug"))
|
20
|
-
|
17
|
+
FileUtils.mkdir_p(log_dir)
|
21
18
|
@log_dir = log_dir
|
22
19
|
$objects_out=open(File.join("log","mongrel_debug","objects.log"),"w")
|
23
20
|
$objects_out.puts "run,classname,last,count,delta,lenmean,lensd,lenmax"
|
data/lib/mongrel/handlers.rb
CHANGED
@@ -98,6 +98,10 @@ module Mongrel
|
|
98
98
|
# that the final expanded path includes the root path. If it doesn't
|
99
99
|
# than it simply gives a 404.
|
100
100
|
#
|
101
|
+
# If you pass nil as the root path, it will not check any locations or
|
102
|
+
# expand any paths. This lets you serve files from multiple directories
|
103
|
+
# on win32.
|
104
|
+
#
|
101
105
|
# The default content type is "text/plain; charset=ISO-8859-1" but you
|
102
106
|
# can change it anything you want using the DirHandler.default_content_type
|
103
107
|
# attribute.
|
@@ -110,9 +114,9 @@ module Mongrel
|
|
110
114
|
|
111
115
|
ONLY_HEAD_GET="Only HEAD and GET allowed.".freeze
|
112
116
|
|
113
|
-
# You give it the path to the directory root and
|
117
|
+
# You give it the path to the directory root and and optional listing_allowed and index_html
|
114
118
|
def initialize(path, listing_allowed=true, index_html="index.html")
|
115
|
-
@path = File.expand_path(path)
|
119
|
+
@path = File.expand_path(path) if path
|
116
120
|
@listing_allowed=listing_allowed
|
117
121
|
@index_html = index_html
|
118
122
|
@default_content_type = "application/octet-stream".freeze
|
@@ -120,7 +124,13 @@ module Mongrel
|
|
120
124
|
|
121
125
|
# Checks if the given path can be served and returns the full path (or nil if not).
|
122
126
|
def can_serve(path_info)
|
123
|
-
|
127
|
+
|
128
|
+
req_path = HttpRequest.unescape(path_info)
|
129
|
+
if @path
|
130
|
+
req_path = File.expand_path(File.join(@path, path_info), @path)
|
131
|
+
else
|
132
|
+
req_path = File.expand_path(req_path)
|
133
|
+
end
|
124
134
|
|
125
135
|
if req_path.index(@path) == 0 and File.exist? req_path
|
126
136
|
# it exists and it's in the right location
|
@@ -208,11 +218,14 @@ module Mongrel
|
|
208
218
|
if same_response
|
209
219
|
response.start(304) {}
|
210
220
|
else
|
211
|
-
|
212
|
-
|
221
|
+
|
222
|
+
# First we setup the headers and status then we do a very fast send on the socket directly
|
223
|
+
|
224
|
+
# Support custom responses except 404, which is the default. A little awkward.
|
225
|
+
response.status = 200 if response.status == 404
|
213
226
|
header[Const::LAST_MODIFIED] = mtime.httpdate
|
214
227
|
|
215
|
-
#
|
228
|
+
# Set the mime type from our map based on the ending
|
216
229
|
dot_at = req_path.rindex('.')
|
217
230
|
if dot_at
|
218
231
|
header[Const::CONTENT_TYPE] = MIME_TYPES[req_path[dot_at .. -1]] || @default_content_type
|
@@ -374,6 +387,7 @@ module Mongrel
|
|
374
387
|
results << table("settings", [
|
375
388
|
["host",listener.host],
|
376
389
|
["port",listener.port],
|
390
|
+
["throttle",listener.throttle],
|
377
391
|
["timeout",listener.timeout],
|
378
392
|
["workers max",listener.num_processors],
|
379
393
|
])
|
@@ -384,8 +398,8 @@ module Mongrel
|
|
384
398
|
end
|
385
399
|
|
386
400
|
results << "<h2>Registered Handlers</h2>"
|
387
|
-
|
388
|
-
results << table("handlers",
|
401
|
+
handler_map = listener.classifier.handler_map
|
402
|
+
results << table("handlers", handler_map.map {|uri,handlers|
|
389
403
|
[uri,
|
390
404
|
"<pre>" +
|
391
405
|
handlers.map {|h| h.class.to_s }.join("\n") +
|
@@ -430,7 +444,7 @@ module Mongrel
|
|
430
444
|
|
431
445
|
def initialize(pattern, replacement = nil, &block)
|
432
446
|
unless replacement or block
|
433
|
-
@replacement = pattern
|
447
|
+
@pattern, @replacement = nil, pattern
|
434
448
|
else
|
435
449
|
@pattern, @replacement, @block = pattern, replacement, block
|
436
450
|
end
|
data/lib/mongrel/mime_types.yml
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
.asp: text/asp
|
19
19
|
.asr: video/x-ms-asf
|
20
20
|
.asx: video/x-ms-asf
|
21
|
-
.atom: application/xml
|
21
|
+
.atom: application/atom+xml
|
22
22
|
.au: audio/basic
|
23
23
|
.au: audio/x-au
|
24
24
|
.avi: video/avi
|
@@ -605,6 +605,7 @@
|
|
605
605
|
.xpix: application/x-vnd.ls-xpix
|
606
606
|
.xpm: image/x-xpixmap
|
607
607
|
.xpm: image/xpm
|
608
|
+
.xsl: application/xslt+xml
|
608
609
|
.xsr: video/x-amt-showrun
|
609
610
|
.xwd: image/x-xwd
|
610
611
|
.xwd: image/x-xwindowdump
|
data/lib/mongrel/rails.rb
CHANGED
@@ -37,7 +37,6 @@ module Mongrel
|
|
37
37
|
def initialize(dir, mime_map = {})
|
38
38
|
@files = Mongrel::DirHandler.new(dir,false)
|
39
39
|
@guard = Mutex.new
|
40
|
-
@tick = Time.now
|
41
40
|
|
42
41
|
# Register the requested MIME types
|
43
42
|
mime_map.each {|k,v| Mongrel::DirHandler::add_mime_type(k,v) }
|
@@ -49,12 +48,13 @@ module Mongrel
|
|
49
48
|
# * If it exists at PATH_INFO+".html" exists then serve that.
|
50
49
|
# * Finally, construct a Mongrel::CGIWrapper and run Dispatcher.dispatch to have Rails go.
|
51
50
|
def process(request, response)
|
52
|
-
if response.socket.closed?
|
53
|
-
|
54
|
-
end
|
55
|
-
|
51
|
+
return if response.socket.closed?
|
52
|
+
|
56
53
|
path_info = request.params[Mongrel::Const::PATH_INFO]
|
57
|
-
|
54
|
+
rest_operator = request.params[Mongrel::Const::REQUEST_URI][/^#{Regexp.escape path_info}(;[^\?]+)/, 1].to_s
|
55
|
+
path_info.chomp!("/")
|
56
|
+
|
57
|
+
page_cached = path_info + rest_operator + ActionController::Base.page_cache_extension
|
58
58
|
get_or_head = @@file_only_methods.include? request.params[Mongrel::Const::REQUEST_METHOD]
|
59
59
|
|
60
60
|
if get_or_head and @files.can_serve(path_info)
|
@@ -71,10 +71,8 @@ module Mongrel
|
|
71
71
|
# We don't want the output to be really final until we're out of the lock
|
72
72
|
cgi.default_really_final = false
|
73
73
|
|
74
|
-
log_threads_waiting_for(@active_request_path || request.params["PATH_INFO"]) if $mongrel_debug_client
|
75
|
-
|
76
74
|
@guard.synchronize {
|
77
|
-
@active_request_path = request.params[
|
75
|
+
@active_request_path = request.params[Mongrel::Const::PATH_INFO]
|
78
76
|
Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)
|
79
77
|
@active_request_path = nil
|
80
78
|
}
|
@@ -90,12 +88,6 @@ module Mongrel
|
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
def log_threads_waiting_for(event)
|
94
|
-
if Time.now - @tick > 10
|
95
|
-
@tick = Time.now
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
91
|
# Does the internal reload for Rails. It might work for most cases, but
|
100
92
|
# sometimes you get exceptions. In that case just do a real restart.
|
101
93
|
def reload!
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDUDCCAjigAwIBAgIBADANBgkqhkiG9w0BAQUFADBOMRwwGgYDVQQDDBNtb25n
|
3
|
+
cmVsLWRldmVsb3BtZW50MRkwFwYKCZImiZPyLGQBGRYJcnVieWZvcmdlMRMwEQYK
|
4
|
+
CZImiZPyLGQBGRYDb3JnMB4XDTA3MDkxNjEwMzI0OVoXDTA4MDkxNTEwMzI0OVow
|
5
|
+
TjEcMBoGA1UEAwwTbW9uZ3JlbC1kZXZlbG9wbWVudDEZMBcGCgmSJomT8ixkARkW
|
6
|
+
CXJ1Ynlmb3JnZTETMBEGCgmSJomT8ixkARkWA29yZzCCASIwDQYJKoZIhvcNAQEB
|
7
|
+
BQADggEPADCCAQoCggEBAMb9v3B01eOHk3FyypbQgKXzJplUE5P6dXoG+xpPm0Lv
|
8
|
+
P7BQmeMncOwqQ7zXpVQU+lTpXtQFTsOE3vL7KnhQFJKGvUAkbh24VFyopu1I0yqF
|
9
|
+
mGu4nRqNXGXVj8TvLSj4S1WpSRLAa0acLPNyKhGmoV9+crqQypSjM6XKjBeppifo
|
10
|
+
4eBmWGjiJEYMIJBvJZPJ4rAVDDA8C6CM1m3gMBGNh8ELDhU8HI9AP3dMIkTI2Wx9
|
11
|
+
9xkJwHdroAaS0IFFtYChrwee4FbCF1FHDgoTosMwa47DrLHg4hZ6ojaKwK5QVWEV
|
12
|
+
XGb6ju5UqpktnSWF2W+Lvl/K0tI42OH2CAhebT1gEVUCAwEAAaM5MDcwCQYDVR0T
|
13
|
+
BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFGHChyMSZ16u9WOzKhgJSQ9lqDc5
|
14
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQA/lfeN2WdB1xN+82tT7vNS4HOjRQw6MUh5yktu
|
15
|
+
GQjaGqm0UB+aX0Z9y0B0qpfv9rj7nmIvEGiwBmDepNWYCGuW15JyqpN7QVVnG2xS
|
16
|
+
Mrame7VqgjM7A+VGDD5In5LtWbM/CHAATvvFlQ5Ph13YE1EdnVbZ65c+KQv+5sFY
|
17
|
+
Q+zEop74d878uaC/SAHHXS46TiXneocaLSYw1CEZs/MAIy+9c4Q5ESbGpgnfg1Ad
|
18
|
+
6lwl7k3hsNHO/+tZzx4HJtOXDI1yAl3+q6T9J0yI3z97EinwvAKhS1eyOI2Y5eeT
|
19
|
+
tbQaNYkU127B3l/VNpd8fQm3Jkl/PqCCmDBQjUszFrJEODug
|
20
|
+
-----END CERTIFICATE-----
|
data/mongrel.gemspec
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Mongrel-1.0.2
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{mongrel}
|
7
|
+
s.version = "1.0.2"
|
8
|
+
|
9
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Zed A. Shaw"]
|
13
|
+
s.date = %q{2007-10-26}
|
14
|
+
s.default_executable = %q{mongrel_rails}
|
15
|
+
s.description = %q{A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.}
|
16
|
+
s.email = %q{}
|
17
|
+
s.executables = ["mongrel_rails"]
|
18
|
+
s.extensions = ["ext/http11/extconf.rb"]
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.homepage = %q{}
|
21
|
+
s.require_paths = ["lib", "ext"]
|
22
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
|
23
|
+
s.rubyforge_project = %q{mongrel}
|
24
|
+
s.rubygems_version = %q{0.9.4.6}
|
25
|
+
s.summary = %q{A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.}
|
26
|
+
s.test_files = ["test/test_cgi_wrapper.rb", "test/test_command.rb", "test/test_conditional.rb", "test/test_configurator.rb", "test/test_debug.rb", "test/test_handlers.rb", "test/test_http11.rb", "test/test_redirect_handler.rb", "test/test_request_progress.rb", "test/test_response.rb", "test/test_stats.rb", "test/test_uriclassifier.rb", "test/test_ws.rb"]
|
27
|
+
|
28
|
+
s.add_dependency(%q<gem_plugin>, [">= 0.2.3"])
|
29
|
+
s.add_dependency(%q<cgi_multipart_eof_fix>, [">= 2.4"])
|
30
|
+
s.add_dependency(%q<daemons>, [">= 1.0.3"])
|
31
|
+
s.add_dependency(%q<fastthread>, [">= 1.0.1"])
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# # Original Rakefile source (requires the Echoe gem):
|
36
|
+
#
|
37
|
+
#
|
38
|
+
# require 'rubygems'
|
39
|
+
# gem 'echoe', '>=2.6.4'
|
40
|
+
# require 'echoe'
|
41
|
+
#
|
42
|
+
# e = Echoe.new("mongrel") do |p|
|
43
|
+
# p.summary = "A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps."
|
44
|
+
# p.author ="Zed A. Shaw"
|
45
|
+
# p.clean_pattern = ['ext/http11/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/http11/Makefile', 'pkg', 'lib/*.bundle', '*.gem', 'site/output', '.config']
|
46
|
+
# p.rdoc_pattern = ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc', 'ext/http11/http11.c']
|
47
|
+
# p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/
|
48
|
+
# p.ruby_version = '>= 1.8.4'
|
49
|
+
# p.dependencies = ['gem_plugin >=0.2.3', 'cgi_multipart_eof_fix >=2.4']
|
50
|
+
#
|
51
|
+
# p.need_tar_gz = false
|
52
|
+
# p.need_tgz = true
|
53
|
+
#
|
54
|
+
# case RUBY_PLATFORM
|
55
|
+
# when /mswin/
|
56
|
+
# else
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# p.eval = proc do
|
60
|
+
# case RUBY_PLATFORM
|
61
|
+
# when /mswin/
|
62
|
+
# extensions.clear
|
63
|
+
# self.files += ['lib/http11.so']
|
64
|
+
# self.platform = Gem::Platform::WIN32
|
65
|
+
# else
|
66
|
+
# add_dependency('daemons', '>= 1.0.3')
|
67
|
+
# add_dependency('fastthread', '>= 1.0.1')
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# #### Ragel builder
|
74
|
+
#
|
75
|
+
# desc "Rebuild the Ragel sources"
|
76
|
+
# task :ragel do
|
77
|
+
# Dir.chdir "ext/http11" do
|
78
|
+
# target = "http11_parser.c"
|
79
|
+
# File.unlink target if File.exist? target
|
80
|
+
# sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}"
|
81
|
+
# raise "Failed to build C source" unless File.exist? target
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# #### XXX Hack around RubyGems and Echoe for pre-compiled extensions.
|
86
|
+
#
|
87
|
+
# def move_extensions
|
88
|
+
# Dir["ext/**/*.#{Config::CONFIG['DLEXT']}"].each { |file| cp file, "lib/" }
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# case RUBY_PLATFORM
|
92
|
+
# when /mswin/
|
93
|
+
# filename = "lib/http11.so"
|
94
|
+
# file filename do
|
95
|
+
# Dir.chdir("ext/http11") do
|
96
|
+
# ruby "extconf.rb"
|
97
|
+
# system(PLATFORM =~ /mswin/ ? 'nmake' : 'make')
|
98
|
+
# end
|
99
|
+
# move_extensions
|
100
|
+
# end
|
101
|
+
# task :compile => [filename]
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# #### Project-wide install and uninstall tasks
|
105
|
+
#
|
106
|
+
# def sub_project(project, *targets)
|
107
|
+
# targets.each do |target|
|
108
|
+
# Dir.chdir "projects/#{project}" do
|
109
|
+
# sh %{rake --trace #{target.to_s} }
|
110
|
+
# end
|
111
|
+
# end
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# desc "Package Mongrel and all subprojects"
|
115
|
+
# task :package_all => [:package] do
|
116
|
+
# sub_project("gem_plugin", :package)
|
117
|
+
# sub_project("cgi_multipart_eof_fix", :package)
|
118
|
+
# sub_project("fastthread", :package)
|
119
|
+
# sub_project("mongrel_status", :package)
|
120
|
+
# sub_project("mongrel_upload_progress", :package)
|
121
|
+
# sub_project("mongrel_console", :package)
|
122
|
+
# sub_project("mongrel_cluster", :package)
|
123
|
+
# sub_project("mongrel_service", :package) if RUBY_PLATFORM =~ /mswin/
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# task :install_requirements do
|
127
|
+
# # These run before Mongrel is installed
|
128
|
+
# sub_project("gem_plugin", :install)
|
129
|
+
# sub_project("cgi_multipart_eof_fix", :install)
|
130
|
+
# sub_project("fastthread", :install)
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# desc "for Mongrel and all subprojects"
|
134
|
+
# task :install => [:install_requirements] do
|
135
|
+
# # These run after Mongrel is installed
|
136
|
+
# sub_project("mongrel_status", :install)
|
137
|
+
# sub_project("mongrel_upload_progress", :install)
|
138
|
+
# sub_project("mongrel_console", :install)
|
139
|
+
# sub_project("mongrel_cluster", :install)
|
140
|
+
# sub_project("mongrel_service", :install) if RUBY_PLATFORM =~ /mswin/
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# desc "for Mongrel and all its subprojects"
|
144
|
+
# task :uninstall => [:clean] do
|
145
|
+
# sub_project("mongrel_status", :uninstall)
|
146
|
+
# sub_project("cgi_multipart_eof_fix", :uninstall)
|
147
|
+
# sub_project("mongrel_upload_progress", :uninstall)
|
148
|
+
# sub_project("mongrel_console", :uninstall)
|
149
|
+
# sub_project("gem_plugin", :uninstall)
|
150
|
+
# sub_project("fastthread", :uninstall)
|
151
|
+
# sub_project("mongrel_service", :install) if RUBY_PLATFORM =~ /mswin/
|
152
|
+
# end
|
153
|
+
#
|
154
|
+
# desc "for Mongrel and all its subprojects"
|
155
|
+
# task :clean do
|
156
|
+
# sub_project("gem_plugin", :clean)
|
157
|
+
# sub_project("cgi_multipart_eof_fix", :clean)
|
158
|
+
# sub_project("fastthread", :clean)
|
159
|
+
# sub_project("mongrel_status", :clean)
|
160
|
+
# sub_project("mongrel_upload_progress", :clean)
|
161
|
+
# sub_project("mongrel_console", :clean)
|
162
|
+
# sub_project("mongrel_cluster", :clean)
|
163
|
+
# sub_project("mongrel_service", :clean) if RUBY_PLATFORM =~ /mswin/
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# #### Site upload tasks
|
167
|
+
#
|
168
|
+
# namespace :site do
|
169
|
+
#
|
170
|
+
# desc "Package and upload .gem files and .tgz files for Mongrel and all subprojects to http://mongrel.rubyforge.org/releases/"
|
171
|
+
# task :source => [:package_all] do
|
172
|
+
# rm_rf "pkg/gems"
|
173
|
+
# rm_rf "pkg/tars"
|
174
|
+
# mkdir_p "pkg/gems"
|
175
|
+
# mkdir_p "pkg/tars"
|
176
|
+
#
|
177
|
+
# FileList["**/*.gem"].each { |gem| mv gem, "pkg/gems" }
|
178
|
+
# FileList["**/*.tgz"].each {|tgz| mv tgz, "pkg/tars" }
|
179
|
+
#
|
180
|
+
# # XXX Hack, because only Luis can package for Win32 right now
|
181
|
+
# sh "cp ~/Downloads/mongrel-1.0.2-mswin32.gem pkg/gems/"
|
182
|
+
# sh "cp ~/Downloads/mongrel_service-0.3.3-mswin32.gem pkg/gems/"
|
183
|
+
# sh "rm -rf pkg/mongrel*"
|
184
|
+
# sh "gem generate_index -d pkg"
|
185
|
+
# sh "scp -r CHANGELOG pkg/* rubyforge.org:/var/www/gforge-projects/mongrel/releases/"
|
186
|
+
# sh "svn log -v > SVN_LOG"
|
187
|
+
# sh "scp -r SVN_LOG pkg/* rubyforge.org:/var/www/gforge-projects/mongrel/releases/"
|
188
|
+
# rm "SVN_LOG"
|
189
|
+
# end
|
190
|
+
#
|
191
|
+
# desc "Upload the website"
|
192
|
+
# task :web do
|
193
|
+
# # Requires the 'webgem' gem and the 'atom-tools' gem
|
194
|
+
# sh "cd site; webgen; ruby atom.rb > output/feed.atom; rsync -azv --no-perms --no-times output/* rubyforge.org:/var/www/gforge-projects/mongrel/"
|
195
|
+
# end
|
196
|
+
#
|
197
|
+
# desc "Upload the rdocs"
|
198
|
+
# task :rdoc => [:redoc] do
|
199
|
+
# sh "rsync -azv doc/* rubyforge.org:/var/www/gforge-projects/mongrel/rdoc/"
|
200
|
+
# sh "cd projects/gem_plugin; rake site"
|
201
|
+
# end
|
202
|
+
#
|
203
|
+
# desc "Upload the coverage report"
|
204
|
+
# task :coverage => [:rcov] do
|
205
|
+
# sh "rsync -azv test/coverage/* rubyforge.org:/var/www/gforge-projects/mongrel/coverage/"
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
# desc "Upload the website, the rdocs, and the coverage report"
|
209
|
+
# task :all => [:web, :rdoc, :coverage]
|
210
|
+
#
|
211
|
+
# end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
# Minimal test to help debug JRuby socket issues
|
3
|
+
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
@server = Thread.new do
|
7
|
+
server_socket = TCPServer.new('0.0.0.0', 10101)
|
8
|
+
this_client = server_socket.accept
|
9
|
+
4.times do |n|
|
10
|
+
begin
|
11
|
+
data = this_client.readpartial(2)
|
12
|
+
puts "Server got: #{data}"
|
13
|
+
if n == 0
|
14
|
+
this_client.close
|
15
|
+
puts "Server closed the client"
|
16
|
+
end
|
17
|
+
rescue IOError => e
|
18
|
+
puts "Server has: #{e.inspect}"
|
19
|
+
end
|
20
|
+
sleep(1)
|
21
|
+
end
|
22
|
+
server_socket.close
|
23
|
+
end
|
24
|
+
|
25
|
+
sleep(3)
|
26
|
+
client_socket = TCPSocket.new('0.0.0.0', 10101)
|
27
|
+
4.times do |n|
|
28
|
+
string = "X#{n}"
|
29
|
+
begin
|
30
|
+
client_socket.write(string)
|
31
|
+
puts "Client said: #{string}"
|
32
|
+
rescue Errno::EPIPE => e
|
33
|
+
puts "Client has: #{e.inspect}"
|
34
|
+
end
|
35
|
+
sleep(1)
|
36
|
+
end
|
37
|
+
client_socket.close
|
38
|
+
|
39
|
+
@server.join
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require 'test/testhelp'
|
3
|
+
|
4
|
+
class MockHttpRequest
|
5
|
+
attr_reader :body
|
6
|
+
|
7
|
+
def params
|
8
|
+
return { 'REQUEST_METHOD' => 'GET'}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class CGIWrapperTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def test_set_cookies_output_cookies
|
15
|
+
request = MockHttpRequest.new
|
16
|
+
response = nil # not needed for this test
|
17
|
+
output_headers = {}
|
18
|
+
|
19
|
+
cgi = Mongrel::CGIWrapper.new(request, response)
|
20
|
+
session = CGI::Session.new(cgi, 'database_manager' => CGI::Session::MemoryStore)
|
21
|
+
cgi.send_cookies(output_headers)
|
22
|
+
|
23
|
+
assert(output_headers.has_key?("Set-Cookie"))
|
24
|
+
assert_equal("_session_id="+session.session_id+"; path=", output_headers["Set-Cookie"])
|
25
|
+
end
|
26
|
+
end
|