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/test/test_command.rb
CHANGED
@@ -4,10 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel'
|
9
|
-
require File.dirname(__FILE__) + '/testhelp.rb'
|
10
|
-
|
7
|
+
require 'test/testhelp'
|
11
8
|
|
12
9
|
class TestCommand < GemPlugin::Plugin "/commands"
|
13
10
|
include Mongrel::Command::Base
|
data/test/test_conditional.rb
CHANGED
@@ -4,19 +4,17 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'net/http'
|
9
|
-
require 'mongrel'
|
7
|
+
require 'test/testhelp'
|
10
8
|
|
11
9
|
include Mongrel
|
12
10
|
|
13
11
|
class ConditionalResponseTest < Test::Unit::TestCase
|
14
12
|
def setup
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
13
|
+
@server = HttpServer.new('127.0.0.1', 3501)
|
14
|
+
@server.register('/', Mongrel::DirHandler.new('.'))
|
15
|
+
@server.run
|
18
16
|
|
19
|
-
@http = Net::HTTP.new(@
|
17
|
+
@http = Net::HTTP.new(@server.host, @server.port)
|
20
18
|
|
21
19
|
# get the ETag and Last-Modified headers
|
22
20
|
@path = '/README'
|
@@ -27,17 +25,7 @@ class ConditionalResponseTest < Test::Unit::TestCase
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def teardown
|
30
|
-
|
31
|
-
|
32
|
-
# temporarily disable the puts method in STDERR to silence warnings from stop
|
33
|
-
class << STDERR
|
34
|
-
define_method(:puts) {}
|
35
|
-
end
|
36
|
-
|
37
|
-
@h.stop
|
38
|
-
ensure
|
39
|
-
# restore STDERR
|
40
|
-
STDERR.reopen(orig_stderr)
|
28
|
+
@server.stop(true)
|
41
29
|
end
|
42
30
|
|
43
31
|
# status should be 304 Not Modified when If-None-Match is the matching ETag
|
data/test/test_configurator.rb
CHANGED
@@ -4,10 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel'
|
9
|
-
require 'net/http'
|
10
|
-
require File.dirname(__FILE__) + "/testhelp.rb"
|
7
|
+
require 'test/testhelp'
|
11
8
|
|
12
9
|
$test_plugin_fired = 0
|
13
10
|
|
@@ -32,10 +29,10 @@ end
|
|
32
29
|
class ConfiguratorTest < Test::Unit::TestCase
|
33
30
|
|
34
31
|
def test_base_handler_config
|
35
|
-
config = nil
|
32
|
+
@config = nil
|
36
33
|
|
37
34
|
redirect_test_io do
|
38
|
-
config = Mongrel::Configurator.new :host => "localhost" do
|
35
|
+
@config = Mongrel::Configurator.new :host => "localhost" do
|
39
36
|
listener :port => 4501 do
|
40
37
|
# 2 in front should run, but the sentinel shouldn't since dirhandler processes the request
|
41
38
|
uri "/", :handler => plugin("/handlers/testplugin")
|
@@ -60,7 +57,7 @@ class ConfiguratorTest < Test::Unit::TestCase
|
|
60
57
|
end
|
61
58
|
|
62
59
|
|
63
|
-
config.listeners.each do |host,listener|
|
60
|
+
@config.listeners.each do |host,listener|
|
64
61
|
assert listener.classifier.uris.length == 3, "Wrong number of registered URIs"
|
65
62
|
assert listener.classifier.uris.include?("/"), "/ not registered"
|
66
63
|
assert listener.classifier.uris.include?("/test"), "/test not registered"
|
@@ -78,7 +75,7 @@ class ConfiguratorTest < Test::Unit::TestCase
|
|
78
75
|
end
|
79
76
|
|
80
77
|
redirect_test_io do
|
81
|
-
config.stop
|
78
|
+
@config.stop(false, true)
|
82
79
|
end
|
83
80
|
|
84
81
|
assert_raise Errno::EBADF, Errno::ECONNREFUSED do
|
data/test/test_debug.rb
CHANGED
@@ -4,23 +4,15 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require '
|
8
|
-
FileUtils.mkdir_p "log/mongrel_debug"
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'mongrel/rails'
|
7
|
+
require 'test/testhelp'
|
12
8
|
require 'mongrel/debug'
|
13
9
|
|
14
|
-
|
15
10
|
class MongrelDbgTest < Test::Unit::TestCase
|
16
11
|
|
17
|
-
def
|
12
|
+
def test_tracing_to_log
|
18
13
|
FileUtils.rm_rf "log/mongrel_debug"
|
19
|
-
MongrelDbg::configure
|
20
|
-
end
|
21
|
-
|
22
14
|
|
23
|
-
|
15
|
+
MongrelDbg::configure
|
24
16
|
out = StringIO.new
|
25
17
|
|
26
18
|
MongrelDbg::begin_trace(:rails)
|
data/test/test_handlers.rb
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'net/http'
|
9
|
-
require 'mongrel'
|
10
|
-
require 'timeout'
|
11
|
-
require File.dirname(__FILE__) + "/testhelp.rb"
|
7
|
+
require 'test/testhelp'
|
12
8
|
|
13
9
|
class SimpleHandler < Mongrel::HttpHandler
|
14
10
|
def process(request, response)
|
@@ -48,15 +44,16 @@ class HandlersTest < Test::Unit::TestCase
|
|
48
44
|
uri "/dumb", :handler => Mongrel::DeflateFilter.new
|
49
45
|
uri "/dumb", :handler => DumbHandler.new, :in_front => true
|
50
46
|
uri "/files", :handler => Mongrel::DirHandler.new("doc")
|
51
|
-
uri "/files_nodir", :handler => Mongrel::DirHandler.new("doc",listing_allowed=false, index_html="none")
|
47
|
+
uri "/files_nodir", :handler => Mongrel::DirHandler.new("doc", listing_allowed=false, index_html="none")
|
52
48
|
uri "/status", :handler => Mongrel::StatusHandler.new(:stats_filter => stats)
|
49
|
+
uri "/relative", :handler => Mongrel::DirHandler.new(nil, listing_allowed=false, index_html="none")
|
53
50
|
end
|
54
51
|
end
|
55
52
|
@config.run
|
56
53
|
end
|
57
54
|
|
58
55
|
def teardown
|
59
|
-
@config.stop
|
56
|
+
@config.stop(false, true)
|
60
57
|
end
|
61
58
|
|
62
59
|
def test_more_web_server
|
@@ -70,6 +67,7 @@ class HandlersTest < Test::Unit::TestCase
|
|
70
67
|
"http://localhost:9998/status",
|
71
68
|
])
|
72
69
|
|
70
|
+
# XXX This can't possibly have good coverage.
|
73
71
|
check_status res, String
|
74
72
|
end
|
75
73
|
|
@@ -78,14 +76,14 @@ class HandlersTest < Test::Unit::TestCase
|
|
78
76
|
# test that no accept-encoding returns a non-deflated response
|
79
77
|
req = h.get("/dumb")
|
80
78
|
assert(
|
81
|
-
!req
|
82
|
-
!req
|
79
|
+
!req['Content-Encoding'] ||
|
80
|
+
!req['Content-Encoding'].include?('deflate'))
|
83
81
|
assert_equal "test", req.body
|
84
82
|
|
85
83
|
req = h.get("/dumb", {"Accept-Encoding" => "deflate"})
|
86
84
|
# -MAX_WBITS stops zlib from looking for a zlib header
|
87
85
|
inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
|
88
|
-
assert req
|
86
|
+
assert req['Content-Encoding'].include?('deflate')
|
89
87
|
assert_equal "test", inflater.inflate(req.body)
|
90
88
|
end
|
91
89
|
end
|
data/test/test_http11.rb
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'http11'
|
9
|
-
require 'mongrel'
|
10
|
-
require 'benchmark'
|
11
|
-
require 'digest/sha1'
|
7
|
+
require 'test/testhelp'
|
12
8
|
|
13
9
|
include Mongrel
|
14
10
|
|
@@ -19,10 +15,21 @@ class HttpParserTest < Test::Unit::TestCase
|
|
19
15
|
req = {}
|
20
16
|
http = "GET / HTTP/1.1\r\n\r\n"
|
21
17
|
nread = parser.execute(req, http, 0)
|
18
|
+
|
22
19
|
assert nread == http.length, "Failed to parse the full HTTP request"
|
23
20
|
assert parser.finished?, "Parser didn't finish"
|
24
21
|
assert !parser.error?, "Parser had error"
|
25
22
|
assert nread == parser.nread, "Number read returned from execute does not match"
|
23
|
+
|
24
|
+
assert_equal 'HTTP/1.1', req['SERVER_PROTOCOL']
|
25
|
+
assert_equal '/', req['REQUEST_PATH']
|
26
|
+
assert_equal 'HTTP/1.1', req['HTTP_VERSION']
|
27
|
+
assert_equal '/', req['REQUEST_URI']
|
28
|
+
assert_equal 'CGI/1.2', req['GATEWAY_INTERFACE']
|
29
|
+
assert_equal 'GET', req['REQUEST_METHOD']
|
30
|
+
assert_nil req['FRAGMENT']
|
31
|
+
assert_nil req['QUERY_STRING']
|
32
|
+
|
26
33
|
parser.reset
|
27
34
|
assert parser.nread == 0, "Number read after reset should be 0"
|
28
35
|
end
|
@@ -62,6 +69,18 @@ class HttpParserTest < Test::Unit::TestCase
|
|
62
69
|
assert parser.error?, "Parser SHOULD have error"
|
63
70
|
end
|
64
71
|
|
72
|
+
def test_fragment_in_uri
|
73
|
+
parser = HttpParser.new
|
74
|
+
req = {}
|
75
|
+
get = "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n\r\n"
|
76
|
+
assert_nothing_raised do
|
77
|
+
parser.execute(req, get, 0)
|
78
|
+
end
|
79
|
+
assert parser.finished?
|
80
|
+
assert_equal '/forums/1/topics/2375?page=1', req['REQUEST_URI']
|
81
|
+
assert_equal 'posts-17408', req['FRAGMENT']
|
82
|
+
end
|
83
|
+
|
65
84
|
# lame random garbage maker
|
66
85
|
def rand_data(min, max, readable=true)
|
67
86
|
count = min + ((rand(max)+1) *10).to_i
|
@@ -4,11 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel'
|
9
|
-
require 'net/http'
|
10
|
-
require 'uri'
|
11
|
-
require 'timeout'
|
7
|
+
require 'test/testhelp'
|
12
8
|
|
13
9
|
class RedirectHandlerTest < Test::Unit::TestCase
|
14
10
|
|
@@ -19,7 +15,7 @@ class RedirectHandlerTest < Test::Unit::TestCase
|
|
19
15
|
end
|
20
16
|
|
21
17
|
def teardown
|
22
|
-
@server.stop
|
18
|
+
@server.stop(true)
|
23
19
|
end
|
24
20
|
|
25
21
|
def test_simple_redirect
|
@@ -4,11 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel'
|
9
|
-
require 'net/http'
|
10
|
-
require File.dirname(__FILE__) + '/testhelp.rb'
|
11
|
-
|
7
|
+
require 'test/testhelp'
|
12
8
|
|
13
9
|
class UploadBeginHandler < Mongrel::HttpHandler
|
14
10
|
attr_reader :request_began, :request_progressed, :request_processed
|
@@ -18,9 +14,9 @@ class UploadBeginHandler < Mongrel::HttpHandler
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def reset
|
21
|
-
@request_began =
|
22
|
-
|
23
|
-
|
17
|
+
@request_began = false
|
18
|
+
@request_progressed = false
|
19
|
+
@request_processed = false
|
24
20
|
end
|
25
21
|
|
26
22
|
def request_begins(params)
|
@@ -49,7 +45,7 @@ class RequestProgressTest < Test::Unit::TestCase
|
|
49
45
|
end
|
50
46
|
|
51
47
|
def teardown
|
52
|
-
@server.stop
|
48
|
+
@server.stop(true)
|
53
49
|
end
|
54
50
|
|
55
51
|
def test_begin_end_progress
|
data/test/test_response.rb
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel'
|
9
|
-
require 'benchmark'
|
7
|
+
require 'test/testhelp'
|
10
8
|
|
11
9
|
include Mongrel
|
12
10
|
|
@@ -102,5 +100,28 @@ class ResponseTest < Test::Unit::TestCase
|
|
102
100
|
assert io.length > 0, "output didn't have data"
|
103
101
|
assert io.read[-contents.length..-1] == contents, "output doesn't end with file payload"
|
104
102
|
end
|
103
|
+
|
104
|
+
def test_response_with_custom_reason
|
105
|
+
reason = "You made a bad request"
|
106
|
+
io = StringIO.new
|
107
|
+
resp = HttpResponse.new(io)
|
108
|
+
resp.start(400, false, reason) { |head,out| }
|
109
|
+
resp.finished
|
110
|
+
|
111
|
+
io.rewind
|
112
|
+
assert_match(/.* #{reason}$/, io.readline.chomp, "wrong custom reason phrase")
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_response_with_default_reason
|
116
|
+
code = 400
|
117
|
+
io = StringIO.new
|
118
|
+
resp = HttpResponse.new(io)
|
119
|
+
resp.start(code) { |head,out| }
|
120
|
+
resp.finished
|
121
|
+
|
122
|
+
io.rewind
|
123
|
+
assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, io.readline.chomp, "wrong default reason phrase")
|
124
|
+
end
|
125
|
+
|
105
126
|
end
|
106
127
|
|
data/test/test_stats.rb
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'mongrel/stats'
|
9
|
-
require 'stringio'
|
7
|
+
require 'test/testhelp'
|
10
8
|
|
11
9
|
class StatsTest < Test::Unit::TestCase
|
12
10
|
|
data/test/test_uriclassifier.rb
CHANGED
@@ -4,169 +4,258 @@
|
|
4
4
|
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
5
5
|
# for more information.
|
6
6
|
|
7
|
-
require 'test/
|
8
|
-
require 'net/http'
|
9
|
-
require 'mongrel'
|
10
|
-
require 'benchmark'
|
7
|
+
require 'test/testhelp'
|
11
8
|
|
12
9
|
include Mongrel
|
13
10
|
|
14
11
|
class URIClassifierTest < Test::Unit::TestCase
|
15
12
|
|
16
13
|
def test_uri_finding
|
17
|
-
|
18
|
-
|
14
|
+
uri_classifier = URIClassifier.new
|
15
|
+
uri_classifier.register("/test", 1)
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal
|
23
|
-
|
17
|
+
script_name, path_info, value = uri_classifier.resolve("/test")
|
18
|
+
assert_equal 1, value
|
19
|
+
assert_equal "/test", script_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_root_handler_only
|
23
|
+
uri_classifier = URIClassifier.new
|
24
|
+
uri_classifier.register("/", 1)
|
25
|
+
|
26
|
+
script_name, path_info, value = uri_classifier.resolve("/test")
|
27
|
+
assert_equal 1, value
|
28
|
+
assert_equal "/", script_name
|
29
|
+
assert_equal "/test", path_info
|
24
30
|
end
|
25
|
-
|
26
31
|
|
27
32
|
def test_uri_prefix_ops
|
28
33
|
test = "/pre/fix/test"
|
29
34
|
prefix = "/pre"
|
30
35
|
|
31
|
-
|
32
|
-
|
36
|
+
uri_classifier = URIClassifier.new
|
37
|
+
uri_classifier.register(prefix,1)
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal prefix,
|
38
|
-
assert_equal test[
|
39
|
+
script_name, path_info, value = uri_classifier.resolve(prefix)
|
40
|
+
script_name, path_info, value = uri_classifier.resolve(test)
|
41
|
+
assert_equal 1, value
|
42
|
+
assert_equal prefix, script_name
|
43
|
+
assert_equal test[script_name.length .. -1], path_info
|
39
44
|
|
40
|
-
assert
|
41
|
-
|
45
|
+
assert uri_classifier.inspect
|
46
|
+
assert_equal prefix, uri_classifier.uris[0]
|
42
47
|
end
|
43
48
|
|
44
49
|
def test_not_finding
|
45
50
|
test = "/cant/find/me"
|
46
|
-
|
47
|
-
|
51
|
+
uri_classifier = URIClassifier.new
|
52
|
+
uri_classifier.register(test, 1)
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
script_name, path_info, value = uri_classifier.resolve("/nope/not/here")
|
55
|
+
assert_nil script_name
|
56
|
+
assert_nil path_info
|
57
|
+
assert_nil value
|
53
58
|
end
|
54
59
|
|
55
60
|
def test_exceptions
|
56
|
-
|
61
|
+
uri_classifier = URIClassifier.new
|
57
62
|
|
58
|
-
|
63
|
+
uri_classifier.register("/test", 1)
|
59
64
|
|
60
65
|
failed = false
|
61
66
|
begin
|
62
|
-
|
67
|
+
uri_classifier.register("/test", 1)
|
63
68
|
rescue => e
|
64
69
|
failed = true
|
65
70
|
end
|
66
71
|
|
67
|
-
assert failed
|
72
|
+
assert failed
|
68
73
|
|
69
74
|
failed = false
|
70
75
|
begin
|
71
|
-
|
76
|
+
uri_classifier.register("", 1)
|
72
77
|
rescue => e
|
73
78
|
failed = true
|
74
79
|
end
|
75
80
|
|
76
|
-
assert failed
|
81
|
+
assert failed
|
77
82
|
end
|
78
83
|
|
79
84
|
|
80
85
|
def test_register_unregister
|
81
|
-
|
86
|
+
uri_classifier = URIClassifier.new
|
82
87
|
|
83
88
|
100.times do
|
84
|
-
|
85
|
-
|
86
|
-
assert_equal 1,
|
89
|
+
uri_classifier.register("/stuff", 1)
|
90
|
+
value = uri_classifier.unregister("/stuff")
|
91
|
+
assert_equal 1, value
|
87
92
|
end
|
88
93
|
|
89
|
-
|
90
|
-
|
91
|
-
assert_equal 1,
|
94
|
+
uri_classifier.register("/things",1)
|
95
|
+
script_name, path_info, value = uri_classifier.resolve("/things")
|
96
|
+
assert_equal 1, value
|
92
97
|
|
93
|
-
|
94
|
-
|
95
|
-
|
98
|
+
uri_classifier.unregister("/things")
|
99
|
+
script_name, path_info, value = uri_classifier.resolve("/things")
|
100
|
+
assert_nil value
|
96
101
|
|
97
102
|
end
|
98
103
|
|
99
104
|
|
100
105
|
def test_uri_branching
|
101
|
-
|
102
|
-
|
103
|
-
|
106
|
+
uri_classifier = URIClassifier.new
|
107
|
+
uri_classifier.register("/test", 1)
|
108
|
+
uri_classifier.register("/test/this",2)
|
104
109
|
|
105
|
-
|
106
|
-
|
107
|
-
assert_equal "/test",
|
108
|
-
assert_equal "/that",
|
109
|
-
assert_equal 1,
|
110
|
+
script_name, path_info, handler = uri_classifier.resolve("/test")
|
111
|
+
script_name, path_info, handler = uri_classifier.resolve("/test/that")
|
112
|
+
assert_equal "/test", script_name, "failed to properly find script off branch portion of uri"
|
113
|
+
assert_equal "/that", path_info
|
114
|
+
assert_equal 1, handler, "wrong result for branching uri"
|
110
115
|
end
|
111
116
|
|
112
117
|
def test_all_prefixing
|
113
118
|
tests = ["/test","/test/that","/test/this"]
|
114
119
|
uri = "/test/this/that"
|
115
|
-
|
120
|
+
uri_classifier = URIClassifier.new
|
116
121
|
|
117
|
-
|
122
|
+
current = ""
|
118
123
|
uri.each_byte do |c|
|
119
|
-
|
120
|
-
|
124
|
+
current << c.chr
|
125
|
+
uri_classifier.register(current, c)
|
121
126
|
end
|
122
127
|
|
123
|
-
#
|
128
|
+
# Try to resolve everything with no asserts as a fuzzing
|
124
129
|
tests.each do |prefix|
|
125
|
-
|
130
|
+
current = ""
|
126
131
|
prefix.each_byte do |c|
|
127
|
-
|
128
|
-
|
129
|
-
assert
|
130
|
-
assert
|
131
|
-
assert
|
132
|
+
current << c.chr
|
133
|
+
script_name, path_info, handler = uri_classifier.resolve(current)
|
134
|
+
assert script_name
|
135
|
+
assert path_info
|
136
|
+
assert handler
|
132
137
|
end
|
133
138
|
end
|
134
139
|
|
135
|
-
#
|
140
|
+
# Assert that we find stuff
|
136
141
|
tests.each do |t|
|
137
|
-
|
138
|
-
assert
|
142
|
+
script_name, path_info, handler = uri_classifier.resolve(t)
|
143
|
+
assert handler
|
139
144
|
end
|
140
145
|
|
141
|
-
#
|
142
|
-
|
143
|
-
assert_nil
|
144
|
-
assert_nil
|
145
|
-
assert_nil
|
146
|
+
# Assert we don't find stuff
|
147
|
+
script_name, path_info, handler = uri_classifier.resolve("chicken")
|
148
|
+
assert_nil handler
|
149
|
+
assert_nil script_name
|
150
|
+
assert_nil path_info
|
146
151
|
end
|
147
152
|
|
148
153
|
|
149
154
|
# Verifies that a root mounted ("/") handler resolves
|
150
155
|
# such that path info matches the original URI.
|
151
|
-
# This is needed to
|
156
|
+
# This is needed to accommodate real usage of handlers.
|
152
157
|
def test_root_mounted
|
153
|
-
|
158
|
+
uri_classifier = URIClassifier.new
|
154
159
|
root = "/"
|
155
160
|
path = "/this/is/a/test"
|
156
161
|
|
157
|
-
|
162
|
+
uri_classifier.register(root, 1)
|
158
163
|
|
159
|
-
|
160
|
-
assert_equal 1,
|
161
|
-
assert_equal root,
|
162
|
-
assert_equal root,
|
164
|
+
script_name, path_info, handler = uri_classifier.resolve(root)
|
165
|
+
assert_equal 1, handler
|
166
|
+
assert_equal root, path_info
|
167
|
+
assert_equal root, script_name
|
163
168
|
|
164
|
-
|
165
|
-
assert_equal path,
|
166
|
-
assert_equal root,
|
167
|
-
assert_equal 1,
|
169
|
+
script_name, path_info, handler = uri_classifier.resolve(path)
|
170
|
+
assert_equal path, path_info
|
171
|
+
assert_equal root, script_name
|
172
|
+
assert_equal 1, handler
|
168
173
|
end
|
169
174
|
|
170
|
-
|
175
|
+
# Verifies that a root mounted ("/") handler
|
176
|
+
# is the default point, doesn't matter the order we use
|
177
|
+
# to register the URIs
|
178
|
+
def test_classifier_order
|
179
|
+
tests = ["/before", "/way_past"]
|
180
|
+
root = "/"
|
181
|
+
path = "/path"
|
182
|
+
|
183
|
+
uri_classifier = URIClassifier.new
|
184
|
+
uri_classifier.register(path, 1)
|
185
|
+
uri_classifier.register(root, 2)
|
186
|
+
|
187
|
+
tests.each do |uri|
|
188
|
+
script_name, path_info, handler = uri_classifier.resolve(uri)
|
189
|
+
# p uri_classifier.resolve(uri)
|
190
|
+
assert_equal root, script_name, "#{uri} did not resolve to #{root}"
|
191
|
+
assert_equal uri, path_info
|
192
|
+
assert_equal 2, handler
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
if ENV['BENCHMARK']
|
197
|
+
# Eventually we will have a suite of benchmarks instead of lamely installing a test
|
198
|
+
|
199
|
+
def test_benchmark
|
200
|
+
|
201
|
+
# This URI set should favor a TST. Both versions increase linearly until you hit 14
|
202
|
+
# URIs, then the TST flattens out.
|
203
|
+
@uris = %w(
|
204
|
+
/
|
205
|
+
/dag /dig /digbark /dog /dogbark /dog/bark /dug /dugbarking /puppy
|
206
|
+
/c /cat /cat/tree /cat/tree/mulberry /cats /cot /cot/tree/mulberry /kitty /kittycat
|
207
|
+
# /eag /eig /eigbark /eog /eogbark /eog/bark /eug /eugbarking /iuppy
|
208
|
+
# /f /fat /fat/tree /fat/tree/mulberry /fats /fot /fot/tree/mulberry /jitty /jittyfat
|
209
|
+
# /gag /gig /gigbark /gog /gogbark /gog/bark /gug /gugbarking /kuppy
|
210
|
+
# /h /hat /hat/tree /hat/tree/mulberry /hats /hot /hot/tree/mulberry /litty /littyhat
|
211
|
+
# /ceag /ceig /ceigbark /ceog /ceogbark /ceog/cbark /ceug /ceugbarking /ciuppy
|
212
|
+
# /cf /cfat /cfat/ctree /cfat/ctree/cmulberry /cfats /cfot /cfot/ctree/cmulberry /cjitty /cjittyfat
|
213
|
+
# /cgag /cgig /cgigbark /cgog /cgogbark /cgog/cbark /cgug /cgugbarking /ckuppy
|
214
|
+
# /ch /chat /chat/ctree /chat/ctree/cmulberry /chats /chot /chot/ctree/cmulberry /citty /cittyhat
|
215
|
+
)
|
216
|
+
|
217
|
+
@requests = %w(
|
218
|
+
/
|
219
|
+
/dig
|
220
|
+
/digging
|
221
|
+
/dogging
|
222
|
+
/dogbarking/
|
223
|
+
/puppy/barking
|
224
|
+
/c
|
225
|
+
/cat
|
226
|
+
/cat/shrub
|
227
|
+
/cat/tree
|
228
|
+
/cat/tree/maple
|
229
|
+
/cat/tree/mulberry/tree
|
230
|
+
/cat/tree/oak
|
231
|
+
/cats/
|
232
|
+
/cats/tree
|
233
|
+
/cod
|
234
|
+
/zebra
|
235
|
+
)
|
236
|
+
|
237
|
+
@classifier = URIClassifier.new
|
238
|
+
@uris.each do |uri|
|
239
|
+
@classifier.register(uri, 1)
|
240
|
+
end
|
241
|
+
|
242
|
+
puts "#{@uris.size} URIs / #{@requests.size * 10000} requests"
|
243
|
+
|
244
|
+
Benchmark.bm do |x|
|
245
|
+
x.report do
|
246
|
+
# require 'ruby-prof'
|
247
|
+
# profile = RubyProf.profile do
|
248
|
+
10000.times do
|
249
|
+
@requests.each do |request|
|
250
|
+
@classifier.resolve(request)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
# end
|
254
|
+
# File.open("profile.html", 'w') { |file| RubyProf::GraphHtmlPrinter.new(profile).print(file, 0) }
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
171
260
|
end
|
172
261
|
|