mongrel 0.3.12.4 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +44 -33
- data/bin/mongrel_rails +67 -34
- data/doc/rdoc/classes/IO.html +10 -10
- data/doc/rdoc/classes/IO.src/{M000005.html → M000001.html} +5 -5
- data/doc/rdoc/classes/IO.src/{M000006.html → M000002.html} +5 -5
- data/doc/rdoc/classes/Kernel.html +10 -10
- data/doc/rdoc/classes/Kernel.src/{M000025.html → M000020.html} +5 -5
- data/doc/rdoc/classes/Kernel.src/M000021.html +23 -0
- data/doc/rdoc/classes/Mongrel.html +25 -4
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +383 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000096.html +11 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000097.html +34 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +21 -6
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000093.html → M000099.html} +13 -13
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000094.html → M000100.html} +11 -11
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/{M000095.html → M000101.html} +4 -4
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000102.html +18 -0
- data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000084.html → CGIWrapper.src/M000103.html} +5 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000104.html +19 -0
- data/doc/rdoc/classes/Mongrel/Camping.html +5 -5
- data/doc/rdoc/classes/Mongrel/Camping.src/M000046.html +22 -0
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/{M000049.html → M000047.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000048.html +51 -0
- data/doc/rdoc/classes/Mongrel/Command.html +13 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.html +95 -50
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +24 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +42 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +5 -11
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +9 -28
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +11 -9
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +11 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Registry.html +15 -15
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000037.html +20 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/{M000040.html → M000038.html} +11 -11
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +37 -7
- data/doc/rdoc/classes/Mongrel/Configurator.html +651 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +16 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +18 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +7 -11
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +7 -6
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +10 -9
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +5 -8
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +21 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +6 -15
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +17 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +20 -33
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +5 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000116.html +24 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000117.html +19 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000118.html +22 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000119.html +25 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000120.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000121.html +35 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000122.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000123.html +33 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000124.html +18 -0
- data/doc/rdoc/classes/Mongrel/Const.html +39 -7
- data/doc/rdoc/classes/Mongrel/DeflateFilter.html +181 -0
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000094.html +19 -0
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000095.html +28 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.html +48 -33
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +21 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000057.html +43 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +29 -7
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +50 -29
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +26 -27
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +5 -38
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000116.html → M000125.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000117.html → M000126.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +185 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000072.html → M000069.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000073.html → M000070.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +170 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000074.html → M000075.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +20 -10
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/{M000027.html → M000022.html} +5 -4
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/{M000028.html → M000023.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpParser.html +41 -36
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000056.html → M000049.html} +6 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000057.html → M000050.html} +7 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +7 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +37 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +5 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +6 -22
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +6 -5
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +239 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000130.html +52 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000119.html → M000131.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000120.html → M000132.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000121.html → M000133.html} +18 -18
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +439 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +12 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +7 -12
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +12 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +9 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +9 -10
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +9 -5
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +18 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +8 -5
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +20 -0
- data/doc/rdoc/classes/Mongrel/{HttpServer.src/M000069.html → HttpResponse.src/M000085.html} +7 -5
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +20 -0
- data/doc/rdoc/classes/Mongrel/{Configurator.src/M000101.html → HttpResponse.src/M000087.html} +5 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.html +68 -59
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +25 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +83 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +13 -11
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +50 -53
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +21 -11
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +5 -47
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +9 -15
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +16 -16
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000040.html +39 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/{M000043.html → M000041.html} +11 -11
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +13 -22
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +17 -17
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000043.html +22 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000044.html +51 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +10 -9
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +211 -0
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000127.html +24 -0
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000128.html +24 -0
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000129.html +18 -0
- data/doc/rdoc/classes/{Class.html → Mongrel/StatusHandler.html} +42 -45
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +18 -0
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000072.html +24 -0
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000073.html +42 -0
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000074.html +20 -0
- data/doc/rdoc/classes/Mongrel/StopServer.html +117 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +314 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000088.html +5 -23
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html +5 -70
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000086.html → M000090.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000087.html → M000091.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +36 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000093.html +83 -0
- data/doc/rdoc/classes/MongrelDbg.html +25 -25
- data/doc/rdoc/classes/MongrelDbg.src/{M000020.html → M000015.html} +5 -5
- data/doc/rdoc/classes/MongrelDbg.src/{M000021.html → M000016.html} +6 -6
- data/doc/rdoc/classes/MongrelDbg.src/{M000022.html → M000017.html} +8 -8
- data/doc/rdoc/classes/MongrelDbg.src/{M000023.html → M000018.html} +7 -7
- data/doc/rdoc/classes/MongrelDbg.src/{M000024.html → M000019.html} +4 -4
- data/doc/rdoc/classes/ObjectTracker.html +10 -40
- data/doc/rdoc/classes/ObjectTracker.src/M000013.html +27 -0
- data/doc/rdoc/classes/ObjectTracker.src/M000014.html +44 -0
- data/doc/rdoc/classes/RequestLog.html +115 -0
- data/doc/rdoc/classes/RequestLog/Access.html +151 -0
- data/doc/rdoc/classes/RequestLog/Access.src/{M000122.html → M000134.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Files.html +144 -0
- data/doc/rdoc/classes/RequestLog/Files.src/{M000123.html → M000135.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Objects.html +144 -0
- data/doc/rdoc/classes/RequestLog/Objects.src/{M000124.html → M000137.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Params.html +144 -0
- data/doc/rdoc/classes/RequestLog/Params.src/{M000125.html → M000138.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Threads.html +144 -0
- data/doc/rdoc/classes/RequestLog/Threads.src/M000136.html +34 -0
- data/doc/rdoc/classes/Stats.html +54 -36
- data/doc/rdoc/classes/Stats.src/{M000013.html → M000005.html} +6 -5
- data/doc/rdoc/classes/Stats.src/M000006.html +23 -0
- data/doc/rdoc/classes/Stats.src/M000007.html +26 -0
- data/doc/rdoc/classes/Stats.src/M000008.html +18 -0
- data/doc/rdoc/classes/Stats.src/M000009.html +5 -6
- data/doc/rdoc/classes/Stats.src/M000010.html +5 -10
- data/doc/rdoc/classes/Stats.src/M000011.html +10 -13
- data/doc/rdoc/classes/Stats.src/M000012.html +7 -5
- data/doc/rdoc/classes/TCPServer.html +9 -9
- data/doc/rdoc/classes/TCPServer.src/M000003.html +19 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/COPYING.html +1 -1
- data/doc/rdoc/files/LICENSE.html +1 -1
- data/doc/rdoc/files/README.html +1 -1
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel/camping_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/cgi_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/command_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/debug_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +3 -3
- data/doc/rdoc/files/lib/mongrel/init_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/rails_rb.html +28 -1
- data/doc/rdoc/files/lib/mongrel/stats_rb.html +21 -10
- data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +23 -4
- data/doc/rdoc/files/lib/mongrel_rb.html +33 -1
- data/doc/rdoc/fr_class_index.html +65 -0
- data/doc/rdoc/fr_file_index.html +40 -0
- data/doc/rdoc/fr_method_index.html +164 -0
- data/doc/rdoc/index.html +24 -0
- data/examples/camping/blog.rb +1 -1
- data/examples/camping/tepee.rb +4 -3
- data/examples/simpletest.rb +15 -14
- data/ext/http11/http11.c +52 -18
- data/ext/http11/http11_parser.c +194 -177
- data/ext/http11/http11_parser.h +23 -5
- data/lib/mongrel.rb +295 -134
- data/lib/mongrel/camping.rb +48 -6
- data/lib/mongrel/cgi.rb +20 -2
- data/lib/mongrel/command.rb +76 -27
- data/lib/mongrel/debug.rb +42 -13
- data/lib/mongrel/handlers.rb +218 -59
- data/lib/mongrel/init.rb +18 -0
- data/lib/mongrel/rails.rb +61 -44
- data/lib/mongrel/stats.rb +30 -2
- data/lib/mongrel/tcphack.rb +18 -0
- data/setup.rb +799 -574
- data/test/mime.yaml +3 -0
- data/test/mongrel.conf +1 -0
- data/test/test_command.rb +101 -0
- data/test/test_conditional.rb +124 -0
- data/test/test_configurator.rb +56 -22
- data/test/test_debug.rb +18 -2
- data/test/test_handlers.rb +105 -0
- data/test/test_http11.rb +27 -9
- data/test/test_response.rb +38 -0
- data/test/test_stats.rb +21 -2
- data/test/test_uriclassifier.rb +18 -0
- data/test/test_ws.rb +105 -19
- data/test/testhelp.rb +36 -0
- data/tools/rakehelp.rb +52 -46
- data/tools/trickletest.rb +37 -0
- metadata +127 -76
- data/doc/rdoc/classes/Class.src/M000001.html +0 -24
- data/doc/rdoc/classes/Class.src/M000002.html +0 -62
- data/doc/rdoc/classes/Class.src/M000003.html +0 -21
- data/doc/rdoc/classes/Class.src/M000004.html +0 -20
- data/doc/rdoc/classes/Kernel.src/M000026.html +0 -25
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000090.html +0 -24
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000091.html +0 -47
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000092.html +0 -34
- data/doc/rdoc/classes/Mongrel/Camping.src/M000048.html +0 -22
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000050.html +0 -27
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000038.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000041.html +0 -46
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +0 -24
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +0 -23
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +0 -32
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +0 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +0 -31
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +0 -40
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000063.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000118.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +0 -26
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +0 -18
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000044.html +0 -32
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +0 -48
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000047.html +0 -23
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000085.html +0 -18
- data/doc/rdoc/classes/ObjectTracker.src/M000016.html +0 -22
- data/doc/rdoc/classes/ObjectTracker.src/M000017.html +0 -18
- data/doc/rdoc/classes/ObjectTracker.src/M000018.html +0 -18
- data/doc/rdoc/classes/ObjectTracker.src/M000019.html +0 -44
- data/doc/rdoc/classes/Stats.src/M000014.html +0 -19
- data/doc/rdoc/classes/Stats.src/M000015.html +0 -20
- data/doc/rdoc/classes/TCPServer.src/M000007.html +0 -19
- data/lib/mongrel/#rails.rb# +0 -178
data/test/mime.yaml
ADDED
data/test/mongrel.conf
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
uri "/fromconf", :handler => Mongrel::Error404Handler.new("test")
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# Mongrel Web Server - A Mostly Ruby Webserver and Library
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
|
19
|
+
require 'test/unit'
|
20
|
+
require 'mongrel'
|
21
|
+
require File.dirname(__FILE__) + '/testhelp.rb'
|
22
|
+
|
23
|
+
|
24
|
+
class TestCommand < GemPlugin::Plugin "/commands"
|
25
|
+
include Mongrel::Command::Base
|
26
|
+
|
27
|
+
def configure
|
28
|
+
options [
|
29
|
+
["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
|
30
|
+
['', '--user USER', "User to run as", :@user, nil],
|
31
|
+
["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false],
|
32
|
+
["-x", "--test", "Used to let the test run failures", :@test, false],
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
def validate
|
37
|
+
valid_dir? ".", "Can't validate current directory."
|
38
|
+
valid_exists? "Rakefile", "Rakefile not there, test is invalid."
|
39
|
+
if @test
|
40
|
+
valid_exist? "BADFILE", "Yeah, badfile"
|
41
|
+
valid_file? "BADFILE", "Not even a file"
|
42
|
+
valid_dir? "BADDIR", "No dir here"
|
43
|
+
valid? false, "Total failure"
|
44
|
+
end
|
45
|
+
|
46
|
+
return @valid
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def run
|
51
|
+
$test_command_ran = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class CommandTest < Test::Unit::TestCase
|
56
|
+
|
57
|
+
def setup
|
58
|
+
$test_command_ran = false
|
59
|
+
end
|
60
|
+
|
61
|
+
def teardown
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_cmd(args)
|
65
|
+
Mongrel::Command::Registry.instance.run args
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_run_command
|
69
|
+
redirect_test_io do
|
70
|
+
run_cmd ["testcommand"]
|
71
|
+
assert $test_command_ran, "command didn't run"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_command_error
|
76
|
+
redirect_test_io do
|
77
|
+
run_cmd ["crapcommand"]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_command_listing
|
82
|
+
redirect_test_io do
|
83
|
+
run_cmd ["help"]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_options
|
88
|
+
redirect_test_io do
|
89
|
+
run_cmd ["testcommand","-h"]
|
90
|
+
run_cmd ["testcommand","--help"]
|
91
|
+
run_cmd ["testcommand","-e","test","-d","--user"]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_version
|
96
|
+
redirect_test_io do
|
97
|
+
run_cmd ["testcommand", "--version"]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Mongrel Web Server - A Mostly Ruby Webserver and Library
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
|
19
|
+
require 'test/unit'
|
20
|
+
require 'net/http'
|
21
|
+
require 'mongrel'
|
22
|
+
|
23
|
+
include Mongrel
|
24
|
+
|
25
|
+
class HttpParserTest < Test::Unit::TestCase
|
26
|
+
def setup
|
27
|
+
@h = HttpServer.new('127.0.0.1', 3501)
|
28
|
+
@h.register('/', Mongrel::DirHandler.new('.'))
|
29
|
+
@h.run
|
30
|
+
|
31
|
+
@http = Net::HTTP.new(@h.host, @h.port)
|
32
|
+
|
33
|
+
# get the ETag and Last-Modified headers
|
34
|
+
@path = '/README'
|
35
|
+
res = @http.start { |http| http.get(@path) }
|
36
|
+
assert_not_nil @etag = res['ETag']
|
37
|
+
assert_not_nil @last_modified = res['Last-Modified']
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
orig_stderr = STDERR.dup
|
42
|
+
|
43
|
+
# temporarily disable the puts method in STDERR to silence warnings from stop
|
44
|
+
class << STDERR
|
45
|
+
define_method(:puts) {}
|
46
|
+
end
|
47
|
+
|
48
|
+
@h.stop
|
49
|
+
ensure
|
50
|
+
# restore STDERR
|
51
|
+
STDERR.reopen(orig_stderr)
|
52
|
+
end
|
53
|
+
|
54
|
+
# status should be 304 Not Modified when If-None-Match is the matching ETag
|
55
|
+
def test_not_modified_via_if_none_match
|
56
|
+
assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag
|
57
|
+
end
|
58
|
+
|
59
|
+
# status should be 304 Not Modified when If-Unmodified-Since is the matching Last-Modified date
|
60
|
+
def test_not_modified_via_if_unmodified_since
|
61
|
+
assert_status_for_get_and_head Net::HTTPNotModified, 'If-Unmodified-Since' => @last_modified
|
62
|
+
end
|
63
|
+
|
64
|
+
# status should be 304 Not Modified when If-None-Match is the matching ETag
|
65
|
+
# and If-Unmodified-Since is the matching Last-Modified date
|
66
|
+
def test_not_modified_via_if_none_match_and_if_unmodified_since
|
67
|
+
assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag, 'If-Unmodified-Since' => @last_modified
|
68
|
+
end
|
69
|
+
|
70
|
+
# status should be 200 OK when If-None-Match is invalid
|
71
|
+
def test_invalid_if_none_match
|
72
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => 'invalid'
|
73
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => 'invalid', 'If-Unmodified-Since' => @last_modified
|
74
|
+
end
|
75
|
+
|
76
|
+
# status should be 200 OK when If-Unmodified-Since is invalid
|
77
|
+
def test_invalid_if_unmodified_since
|
78
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-Unmodified-Since' => 'invalid'
|
79
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Unmodified-Since' => 'invalid'
|
80
|
+
end
|
81
|
+
|
82
|
+
# status should be 304 Not Modified when If-Unmodified-Since is greater than the Last-Modified header, but less than the system time
|
83
|
+
def test_if_unmodified_since_greater_than_last_modified
|
84
|
+
sleep 2
|
85
|
+
last_modified_plus_1 = (Time.httpdate(@last_modified) + 1).httpdate
|
86
|
+
assert_status_for_get_and_head Net::HTTPNotModified, 'If-Unmodified-Since' => last_modified_plus_1
|
87
|
+
assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag, 'If-Unmodified-Since' => last_modified_plus_1
|
88
|
+
end
|
89
|
+
|
90
|
+
# status should be 200 OK when If-Unmodified-Since is less than the Last-Modified header
|
91
|
+
def test_if_unmodified_since_less_than_last_modified
|
92
|
+
last_modified_minus_1 = (Time.httpdate(@last_modified) - 1).httpdate
|
93
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-Unmodified-Since' => last_modified_minus_1
|
94
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Unmodified-Since' => last_modified_minus_1
|
95
|
+
end
|
96
|
+
|
97
|
+
# status should be 200 OK when If-Unmodified-Since is a date in the future
|
98
|
+
def test_future_if_unmodified_since
|
99
|
+
the_future = Time.at(2**31-1).httpdate
|
100
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-Unmodified-Since' => the_future
|
101
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Unmodified-Since' => the_future
|
102
|
+
end
|
103
|
+
|
104
|
+
# status should be 200 OK when If-None-Match is a wildcard
|
105
|
+
def test_wildcard_match
|
106
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => '*'
|
107
|
+
assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => '*', 'If-Unmodified-Since' => @last_modified
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
# assert the response status is correct for GET and HEAD
|
113
|
+
def assert_status_for_get_and_head(status_class, headers = {})
|
114
|
+
%w{ get head }.each do |method|
|
115
|
+
res = @http.send(method, @path, headers)
|
116
|
+
assert_kind_of status_class, res
|
117
|
+
assert_equal @etag, res['ETag']
|
118
|
+
case status_class
|
119
|
+
when Net::HTTPNotModified : assert_nil res['Last-Modified']
|
120
|
+
when Net::HTTPOK : assert_equal @last_modified, res['Last-Modified']
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/test/test_configurator.rb
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
+
# Mongrel Web Server - A Mostly Ruby Webserver and Library
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
|
1
19
|
require 'test/unit'
|
2
20
|
require 'mongrel'
|
21
|
+
require 'net/http'
|
22
|
+
require File.dirname(__FILE__) + "/testhelp.rb"
|
3
23
|
|
4
24
|
$test_plugin_fired = 0
|
5
25
|
|
@@ -24,43 +44,57 @@ end
|
|
24
44
|
class ConfiguratorTest < Test::Unit::TestCase
|
25
45
|
|
26
46
|
def test_base_handler_config
|
27
|
-
config =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
config = nil
|
48
|
+
|
49
|
+
redirect_test_io do
|
50
|
+
config = Mongrel::Configurator.new :host => "localhost" do
|
51
|
+
listener :port => 4501 do
|
52
|
+
# 2 in front should run, but the sentinel shouldn't since dirhandler processes the request
|
53
|
+
uri "/", :handler => plugin("/handlers/testplugin")
|
54
|
+
uri "/", :handler => plugin("/handlers/testplugin")
|
55
|
+
uri "/", :handler => Mongrel::DirHandler.new(".")
|
56
|
+
uri "/", :handler => plugin("/handlers/testplugin")
|
57
|
+
|
58
|
+
uri "/test", :handler => plugin("/handlers/testplugin")
|
59
|
+
uri "/test", :handler => plugin("/handlers/testplugin")
|
60
|
+
uri "/test", :handler => Mongrel::DirHandler.new(".")
|
61
|
+
uri "/test", :handler => plugin("/handlers/testplugin")
|
62
|
+
|
63
|
+
debug "/"
|
64
|
+
setup_signals
|
65
|
+
|
66
|
+
run_config(File.dirname(__FILE__) + "/../test/mongrel.conf")
|
67
|
+
load_mime_map(File.dirname(__FILE__) + "/../test/mime.yaml")
|
68
|
+
|
69
|
+
run
|
70
|
+
end
|
40
71
|
end
|
41
72
|
end
|
42
73
|
|
43
74
|
|
44
75
|
config.listeners.each do |host,listener|
|
45
|
-
|
46
|
-
assert listener.classifier.uris.length == 2, "Wrong number of registered URIs"
|
76
|
+
assert listener.classifier.uris.length == 3, "Wrong number of registered URIs"
|
47
77
|
assert listener.classifier.uris.include?("/"), "/ not registered"
|
48
78
|
assert listener.classifier.uris.include?("/test"), "/test not registered"
|
49
79
|
end
|
50
80
|
|
51
|
-
res = Net::HTTP.get(URI.parse('http://localhost:
|
81
|
+
res = Net::HTTP.get(URI.parse('http://localhost:4501/test'))
|
52
82
|
assert res != nil, "Didn't get a response"
|
53
83
|
assert $test_plugin_fired == 3, "Test filter plugin didn't run 3 times."
|
54
84
|
|
85
|
+
redirect_test_io do
|
86
|
+
res = Net::HTTP.get(URI.parse('http://localhost:4501/'))
|
55
87
|
|
56
|
-
|
57
|
-
|
58
|
-
|
88
|
+
assert res != nil, "Didn't get a response"
|
89
|
+
assert $test_plugin_fired == 6, "Test filter plugin didn't run 6 times."
|
90
|
+
end
|
91
|
+
|
92
|
+
redirect_test_io do
|
93
|
+
config.stop
|
94
|
+
end
|
59
95
|
|
60
|
-
config.stop
|
61
|
-
|
62
96
|
assert_raise Errno::EBADF, Errno::ECONNREFUSED do
|
63
|
-
res = Net::HTTP.get(URI.parse("http://localhost:
|
97
|
+
res = Net::HTTP.get(URI.parse("http://localhost:4501/"))
|
64
98
|
end
|
65
99
|
end
|
66
100
|
|
data/test/test_debug.rb
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# Mongrel Web Server - A Mostly Ruby Webserver and Library
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
|
1
19
|
require 'fileutils'
|
2
20
|
FileUtils.mkdir_p "log/mongrel_debug"
|
3
21
|
|
@@ -22,8 +40,6 @@ class MongrelDbgTest < Test::Unit::TestCase
|
|
22
40
|
MongrelDbg::end_trace(:rails)
|
23
41
|
|
24
42
|
assert File.exist?("log/mongrel_debug"), "Didn't make logging directory"
|
25
|
-
assert File.exist?("log/mongrel_debug/rails.log"), "Didn't make the rails.log file"
|
26
|
-
assert File.size("log/mongrel_debug/rails.log") > 0, "Didn't write anything to the log."
|
27
43
|
end
|
28
44
|
|
29
45
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# Mongrel Web Server - A Mostly Ruby Webserver and Library
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18
|
+
|
19
|
+
require 'test/unit'
|
20
|
+
require 'net/http'
|
21
|
+
require 'mongrel'
|
22
|
+
require 'timeout'
|
23
|
+
require File.dirname(__FILE__) + "/testhelp.rb"
|
24
|
+
|
25
|
+
class SimpleHandler < Mongrel::HttpHandler
|
26
|
+
def process(request, response)
|
27
|
+
response.start do |head,out|
|
28
|
+
head["Content-Type"] = "text/html"
|
29
|
+
results = "<html><body>Your request:<br /><pre>#{request.params.to_yaml}</pre><a href=\"/files\">View the files.</a></body></html>"
|
30
|
+
out << results
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class DumbHandler < Mongrel::HttpHandler
|
36
|
+
def process(request, response)
|
37
|
+
response.start do |head,out|
|
38
|
+
head["Content-Type"] = "text/html"
|
39
|
+
out.write("test")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_status(results, expecting)
|
45
|
+
results.each do |res|
|
46
|
+
assert(res.kind_of?(expecting), "Didn't get #{expecting}, got: #{res.class}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class HandlersTest < Test::Unit::TestCase
|
51
|
+
|
52
|
+
def setup
|
53
|
+
stats = Mongrel::StatisticsFilter.new(:sample_rate => 1)
|
54
|
+
|
55
|
+
@config = Mongrel::Configurator.new :host => '127.0.0.1', :port => 9998 do
|
56
|
+
listener do
|
57
|
+
uri "/", :handler => SimpleHandler.new
|
58
|
+
uri "/", :handler => stats
|
59
|
+
uri "/404", :handler => Mongrel::Error404Handler.new("Not found")
|
60
|
+
uri "/dumb", :handler => Mongrel::DeflateFilter.new(:always_deflate => true)
|
61
|
+
uri "/dumb", :handler => DumbHandler.new, :in_front => true
|
62
|
+
uri "/files", :handler => Mongrel::DirHandler.new("doc")
|
63
|
+
uri "/files_nodir", :handler => Mongrel::DirHandler.new("doc",listing_allowed=false, index_html="none")
|
64
|
+
uri "/status", :handler => Mongrel::StatusHandler.new(:stats_filter => stats)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@config.run
|
68
|
+
end
|
69
|
+
|
70
|
+
def teardown
|
71
|
+
@config.stop
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_more_web_server
|
75
|
+
res = hit([ "http://localhost:9998/test",
|
76
|
+
"http://localhost:9998/dumb",
|
77
|
+
"http://localhost:9998/404",
|
78
|
+
"http://localhost:9998/files/rdoc/index.html",
|
79
|
+
"http://localhost:9998/files/rdoc/nothere.html",
|
80
|
+
"http://localhost:9998/files/rdoc/",
|
81
|
+
"http://localhost:9998/files_nodir/rdoc/",
|
82
|
+
"http://localhost:9998/status",
|
83
|
+
])
|
84
|
+
|
85
|
+
check_status res, String
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_deflate_access
|
89
|
+
req = Net::HTTP::Get.new("http://localhost:9998/dumb")
|
90
|
+
end
|
91
|
+
|
92
|
+
# TODO: find out why this fails on win32 but nowhere else
|
93
|
+
#
|
94
|
+
#def test_posting_fails_dirhandler
|
95
|
+
# req = Net::HTTP::Post.new("http://localhost:9998/files/rdoc/")
|
96
|
+
# req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';')
|
97
|
+
# res = hit [["http://localhost:9998/files/rdoc/",req]]
|
98
|
+
# check_status res, Net::HTTPNotFound
|
99
|
+
#end
|
100
|
+
|
101
|
+
def test_unregister
|
102
|
+
@config.listeners["127.0.0.1:9998"].unregister("/")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|