passenger 2.2.7 → 2.2.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/NEWS +40 -0
- data/Rakefile +1 -1
- data/bin/passenger-install-apache2-module +1 -0
- data/bin/passenger-install-nginx-module +2 -0
- data/doc/Architectural overview.html +173 -138
- data/doc/Security of user switching support.html +147 -109
- data/doc/Users guide Apache.html +4 -43
- data/doc/Users guide Nginx.html +4 -43
- data/doc/cxxapi/Bucket_8h-source.html +1 -1
- data/doc/cxxapi/Configuration_8h-source.html +1 -1
- data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
- data/doc/cxxapi/Hooks_8h-source.html +1 -1
- data/doc/cxxapi/annotated.html +1 -1
- data/doc/cxxapi/classHooks-members.html +1 -1
- data/doc/cxxapi/classHooks.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
- data/doc/cxxapi/classes.html +1 -1
- data/doc/cxxapi/definitions_8h-source.html +1 -1
- data/doc/cxxapi/files.html +1 -1
- data/doc/cxxapi/functions.html +1 -1
- data/doc/cxxapi/functions_func.html +1 -1
- data/doc/cxxapi/graph_legend.html +1 -1
- data/doc/cxxapi/group__Configuration.html +1 -1
- data/doc/cxxapi/group__Core.html +1 -1
- data/doc/cxxapi/group__Hooks.html +1 -1
- data/doc/cxxapi/group__Support.html +1 -1
- data/doc/cxxapi/main.html +1 -1
- data/doc/cxxapi/modules.html +1 -1
- data/doc/rdoc/classes/GC.html +4 -4
- data/doc/rdoc/classes/PhusionPassenger.html +2 -1
- data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +8 -8
- data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +26 -26
- data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +98 -98
- data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +61 -61
- data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +4 -4
- data/doc/rdoc/classes/PhusionPassenger/Application.html +14 -14
- data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +12 -12
- data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +4 -4
- data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +12 -12
- data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +5 -5
- data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +42 -42
- data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +33 -33
- data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +59 -59
- data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +3 -3
- data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +7 -7
- data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +23 -23
- data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +4 -4
- data/doc/rdoc/classes/PhusionPassenger/Utils.html +2 -0
- data/doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html +16 -16
- data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +4 -4
- data/doc/rdoc/classes/PlatformInfo.html +1 -1
- data/doc/rdoc/classes/Signal.html +23 -15
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
- data/doc/rdoc/files/README.html +1 -1
- data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +2 -2
- data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +2 -2
- data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +1 -1
- data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +9 -9
- data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +1 -1
- data/doc/rdoc/files/misc/rake/extensions_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +2 -0
- data/doc/rdoc/fr_file_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +79 -72
- data/ext/apache2/Hooks.cpp +4 -2
- data/ext/common/StandardApplicationPool.h +4 -2
- data/ext/common/Version.h +1 -1
- data/ext/nginx/Configuration.c +1 -1
- data/ext/oxt/system_calls.cpp +11 -0
- data/ext/oxt/system_calls.hpp +2 -1
- data/ext/oxt/thread.hpp +97 -1
- data/lib/phusion_passenger/constants.rb +1 -1
- data/lib/phusion_passenger/dependencies.rb +32 -0
- data/lib/phusion_passenger/platform_info.rb +1 -1
- data/lib/phusion_passenger/rack/application_spawner.rb +4 -4
- data/lib/phusion_passenger/rack/request_handler.rb +2 -5
- data/lib/phusion_passenger/railz/application_spawner.rb +13 -2
- data/lib/phusion_passenger/utils.rb +12 -4
- data/{vendor/rack-1.0.0-git/lib/rack → lib/phusion_passenger/utils}/rewindable_input.rb +19 -3
- data/test/ApplicationPoolTest.cpp +1 -1
- metadata +13 -59
- data/vendor/README +0 -13
- data/vendor/README_FOR_PACKAGERS +0 -1
- data/vendor/rack-1.0.0-git/COPYING +0 -18
- data/vendor/rack-1.0.0-git/KNOWN-ISSUES +0 -18
- data/vendor/rack-1.0.0-git/README +0 -353
- data/vendor/rack-1.0.0-git/Rakefile +0 -164
- data/vendor/rack-1.0.0-git/lib/rack.rb +0 -90
- data/vendor/rack-1.0.0-git/lib/rack/adapter/camping.rb +0 -22
- data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/handler.rb +0 -37
- data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/request.rb +0 -37
- data/vendor/rack-1.0.0-git/lib/rack/auth/basic.rb +0 -58
- data/vendor/rack-1.0.0-git/lib/rack/auth/digest/md5.rb +0 -124
- data/vendor/rack-1.0.0-git/lib/rack/auth/digest/nonce.rb +0 -51
- data/vendor/rack-1.0.0-git/lib/rack/auth/digest/params.rb +0 -55
- data/vendor/rack-1.0.0-git/lib/rack/auth/digest/request.rb +0 -40
- data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +0 -487
- data/vendor/rack-1.0.0-git/lib/rack/builder.rb +0 -63
- data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +0 -41
- data/vendor/rack-1.0.0-git/lib/rack/chunked.rb +0 -49
- data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +0 -52
- data/vendor/rack-1.0.0-git/lib/rack/conditionalget.rb +0 -47
- data/vendor/rack-1.0.0-git/lib/rack/content_length.rb +0 -29
- data/vendor/rack-1.0.0-git/lib/rack/content_type.rb +0 -23
- data/vendor/rack-1.0.0-git/lib/rack/deflater.rb +0 -96
- data/vendor/rack-1.0.0-git/lib/rack/directory.rb +0 -153
- data/vendor/rack-1.0.0-git/lib/rack/file.rb +0 -88
- data/vendor/rack-1.0.0-git/lib/rack/handler.rb +0 -69
- data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +0 -61
- data/vendor/rack-1.0.0-git/lib/rack/handler/evented_mongrel.rb +0 -8
- data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +0 -88
- data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +0 -55
- data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +0 -84
- data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +0 -59
- data/vendor/rack-1.0.0-git/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/vendor/rack-1.0.0-git/lib/rack/handler/thin.rb +0 -18
- data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +0 -67
- data/vendor/rack-1.0.0-git/lib/rack/head.rb +0 -19
- data/vendor/rack-1.0.0-git/lib/rack/lint.rb +0 -537
- data/vendor/rack-1.0.0-git/lib/rack/lobster.rb +0 -65
- data/vendor/rack-1.0.0-git/lib/rack/lock.rb +0 -16
- data/vendor/rack-1.0.0-git/lib/rack/methodoverride.rb +0 -27
- data/vendor/rack-1.0.0-git/lib/rack/mime.rb +0 -204
- data/vendor/rack-1.0.0-git/lib/rack/mock.rb +0 -184
- data/vendor/rack-1.0.0-git/lib/rack/recursive.rb +0 -57
- data/vendor/rack-1.0.0-git/lib/rack/reloader.rb +0 -106
- data/vendor/rack-1.0.0-git/lib/rack/request.rb +0 -248
- data/vendor/rack-1.0.0-git/lib/rack/response.rb +0 -183
- data/vendor/rack-1.0.0-git/lib/rack/session/abstract/id.rb +0 -142
- data/vendor/rack-1.0.0-git/lib/rack/session/cookie.rb +0 -91
- data/vendor/rack-1.0.0-git/lib/rack/session/memcache.rb +0 -109
- data/vendor/rack-1.0.0-git/lib/rack/session/pool.rb +0 -100
- data/vendor/rack-1.0.0-git/lib/rack/showexceptions.rb +0 -349
- data/vendor/rack-1.0.0-git/lib/rack/showstatus.rb +0 -106
- data/vendor/rack-1.0.0-git/lib/rack/static.rb +0 -38
- data/vendor/rack-1.0.0-git/lib/rack/urlmap.rb +0 -55
- data/vendor/rack-1.0.0-git/lib/rack/utils.rb +0 -522
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
require 'rack/utils'
|
3
|
-
require 'rack/mime'
|
4
|
-
|
5
|
-
module Rack
|
6
|
-
# Rack::File serves files below the +root+ given, according to the
|
7
|
-
# path info of the Rack request.
|
8
|
-
#
|
9
|
-
# Handlers can detect if bodies are a Rack::File, and use mechanisms
|
10
|
-
# like sendfile on the +path+.
|
11
|
-
|
12
|
-
class File
|
13
|
-
attr_accessor :root
|
14
|
-
attr_accessor :path
|
15
|
-
|
16
|
-
alias :to_path :path
|
17
|
-
|
18
|
-
def initialize(root)
|
19
|
-
@root = root
|
20
|
-
end
|
21
|
-
|
22
|
-
def call(env)
|
23
|
-
dup._call(env)
|
24
|
-
end
|
25
|
-
|
26
|
-
F = ::File
|
27
|
-
|
28
|
-
def _call(env)
|
29
|
-
@path_info = Utils.unescape(env["PATH_INFO"])
|
30
|
-
return forbidden if @path_info.include? ".."
|
31
|
-
|
32
|
-
@path = F.join(@root, @path_info)
|
33
|
-
|
34
|
-
begin
|
35
|
-
if F.file?(@path) && F.readable?(@path)
|
36
|
-
serving
|
37
|
-
else
|
38
|
-
raise Errno::EPERM
|
39
|
-
end
|
40
|
-
rescue SystemCallError
|
41
|
-
not_found
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def forbidden
|
46
|
-
body = "Forbidden\n"
|
47
|
-
[403, {"Content-Type" => "text/plain",
|
48
|
-
"Content-Length" => body.size.to_s},
|
49
|
-
[body]]
|
50
|
-
end
|
51
|
-
|
52
|
-
# NOTE:
|
53
|
-
# We check via File::size? whether this file provides size info
|
54
|
-
# via stat (e.g. /proc files often don't), otherwise we have to
|
55
|
-
# figure it out by reading the whole file into memory. And while
|
56
|
-
# we're at it we also use this as body then.
|
57
|
-
|
58
|
-
def serving
|
59
|
-
if size = F.size?(@path)
|
60
|
-
body = self
|
61
|
-
else
|
62
|
-
body = [F.read(@path)]
|
63
|
-
size = Utils.bytesize(body.first)
|
64
|
-
end
|
65
|
-
|
66
|
-
[200, {
|
67
|
-
"Last-Modified" => F.mtime(@path).httpdate,
|
68
|
-
"Content-Type" => Mime.mime_type(F.extname(@path), 'text/plain'),
|
69
|
-
"Content-Length" => size.to_s
|
70
|
-
}, body]
|
71
|
-
end
|
72
|
-
|
73
|
-
def not_found
|
74
|
-
body = "File not found: #{@path_info}\n"
|
75
|
-
[404, {"Content-Type" => "text/plain",
|
76
|
-
"Content-Length" => body.size.to_s},
|
77
|
-
[body]]
|
78
|
-
end
|
79
|
-
|
80
|
-
def each
|
81
|
-
F.open(@path, "rb") { |file|
|
82
|
-
while part = file.read(8192)
|
83
|
-
yield part
|
84
|
-
end
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module Rack
|
2
|
-
# *Handlers* connect web servers with Rack.
|
3
|
-
#
|
4
|
-
# Rack includes Handlers for Mongrel, WEBrick, FastCGI, CGI, SCGI
|
5
|
-
# and LiteSpeed.
|
6
|
-
#
|
7
|
-
# Handlers usually are activated by calling <tt>MyHandler.run(myapp)</tt>.
|
8
|
-
# A second optional hash can be passed to include server-specific
|
9
|
-
# configuration.
|
10
|
-
module Handler
|
11
|
-
def self.get(server)
|
12
|
-
return unless server
|
13
|
-
server = server.to_s
|
14
|
-
|
15
|
-
if klass = @handlers[server]
|
16
|
-
obj = Object
|
17
|
-
klass.split("::").each { |x| obj = obj.const_get(x) }
|
18
|
-
obj
|
19
|
-
else
|
20
|
-
try_require('rack/handler', server)
|
21
|
-
const_get(server)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Transforms server-name constants to their canonical form as filenames,
|
26
|
-
# then tries to require them but silences the LoadError if not found
|
27
|
-
#
|
28
|
-
# Naming convention:
|
29
|
-
#
|
30
|
-
# Foo # => 'foo'
|
31
|
-
# FooBar # => 'foo_bar.rb'
|
32
|
-
# FooBAR # => 'foobar.rb'
|
33
|
-
# FOObar # => 'foobar.rb'
|
34
|
-
# FOOBAR # => 'foobar.rb'
|
35
|
-
# FooBarBaz # => 'foo_bar_baz.rb'
|
36
|
-
def self.try_require(prefix, const_name)
|
37
|
-
file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }.
|
38
|
-
gsub(/[A-Z]+[^A-Z]/, '_\&').downcase
|
39
|
-
|
40
|
-
require(::File.join(prefix, file))
|
41
|
-
rescue LoadError
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.register(server, klass)
|
45
|
-
@handlers ||= {}
|
46
|
-
@handlers[server] = klass
|
47
|
-
end
|
48
|
-
|
49
|
-
autoload :CGI, "rack/handler/cgi"
|
50
|
-
autoload :FastCGI, "rack/handler/fastcgi"
|
51
|
-
autoload :Mongrel, "rack/handler/mongrel"
|
52
|
-
autoload :EventedMongrel, "rack/handler/evented_mongrel"
|
53
|
-
autoload :SwiftipliedMongrel, "rack/handler/swiftiplied_mongrel"
|
54
|
-
autoload :WEBrick, "rack/handler/webrick"
|
55
|
-
autoload :LSWS, "rack/handler/lsws"
|
56
|
-
autoload :SCGI, "rack/handler/scgi"
|
57
|
-
autoload :Thin, "rack/handler/thin"
|
58
|
-
|
59
|
-
register 'cgi', 'Rack::Handler::CGI'
|
60
|
-
register 'fastcgi', 'Rack::Handler::FastCGI'
|
61
|
-
register 'mongrel', 'Rack::Handler::Mongrel'
|
62
|
-
register 'emongrel', 'Rack::Handler::EventedMongrel'
|
63
|
-
register 'smongrel', 'Rack::Handler::SwiftipliedMongrel'
|
64
|
-
register 'webrick', 'Rack::Handler::WEBrick'
|
65
|
-
register 'lsws', 'Rack::Handler::LSWS'
|
66
|
-
register 'scgi', 'Rack::Handler::SCGI'
|
67
|
-
register 'thin', 'Rack::Handler::Thin'
|
68
|
-
end
|
69
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'rack/content_length'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
module Handler
|
5
|
-
class CGI
|
6
|
-
def self.run(app, options=nil)
|
7
|
-
serve app
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.serve(app)
|
11
|
-
app = ContentLength.new(app)
|
12
|
-
|
13
|
-
env = ENV.to_hash
|
14
|
-
env.delete "HTTP_CONTENT_LENGTH"
|
15
|
-
|
16
|
-
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
|
17
|
-
|
18
|
-
env.update({"rack.version" => [1,0],
|
19
|
-
"rack.input" => $stdin,
|
20
|
-
"rack.errors" => $stderr,
|
21
|
-
|
22
|
-
"rack.multithread" => false,
|
23
|
-
"rack.multiprocess" => true,
|
24
|
-
"rack.run_once" => true,
|
25
|
-
|
26
|
-
"rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
|
27
|
-
})
|
28
|
-
|
29
|
-
env["QUERY_STRING"] ||= ""
|
30
|
-
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
|
31
|
-
env["REQUEST_PATH"] ||= "/"
|
32
|
-
|
33
|
-
status, headers, body = app.call(env)
|
34
|
-
begin
|
35
|
-
send_headers status, headers
|
36
|
-
send_body body
|
37
|
-
ensure
|
38
|
-
body.close if body.respond_to? :close
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.send_headers(status, headers)
|
43
|
-
STDOUT.print "Status: #{status}\r\n"
|
44
|
-
headers.each { |k, vs|
|
45
|
-
vs.split("\n").each { |v|
|
46
|
-
STDOUT.print "#{k}: #{v}\r\n"
|
47
|
-
}
|
48
|
-
}
|
49
|
-
STDOUT.print "\r\n"
|
50
|
-
STDOUT.flush
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.send_body(body)
|
54
|
-
body.each { |part|
|
55
|
-
STDOUT.print part
|
56
|
-
STDOUT.flush
|
57
|
-
}
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'fcgi'
|
2
|
-
require 'socket'
|
3
|
-
require 'rack/content_length'
|
4
|
-
require 'rack/rewindable_input'
|
5
|
-
|
6
|
-
class FCGI::Stream
|
7
|
-
alias _rack_read_without_buffer read
|
8
|
-
|
9
|
-
def read(n, buffer=nil)
|
10
|
-
buf = _rack_read_without_buffer n
|
11
|
-
buffer.replace(buf.to_s) if buffer
|
12
|
-
buf
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module Rack
|
17
|
-
module Handler
|
18
|
-
class FastCGI
|
19
|
-
def self.run(app, options={})
|
20
|
-
file = options[:File] and STDIN.reopen(UNIXServer.new(file))
|
21
|
-
port = options[:Port] and STDIN.reopen(TCPServer.new(port))
|
22
|
-
FCGI.each { |request|
|
23
|
-
serve request, app
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.serve(request, app)
|
28
|
-
app = Rack::ContentLength.new(app)
|
29
|
-
|
30
|
-
env = request.env
|
31
|
-
env.delete "HTTP_CONTENT_LENGTH"
|
32
|
-
|
33
|
-
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
|
34
|
-
|
35
|
-
rack_input = RewindableInput.new(request.in)
|
36
|
-
|
37
|
-
env.update({"rack.version" => [1,0],
|
38
|
-
"rack.input" => rack_input,
|
39
|
-
"rack.errors" => request.err,
|
40
|
-
|
41
|
-
"rack.multithread" => false,
|
42
|
-
"rack.multiprocess" => true,
|
43
|
-
"rack.run_once" => false,
|
44
|
-
|
45
|
-
"rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
|
46
|
-
})
|
47
|
-
|
48
|
-
env["QUERY_STRING"] ||= ""
|
49
|
-
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
|
50
|
-
env["REQUEST_PATH"] ||= "/"
|
51
|
-
env.delete "PATH_INFO" if env["PATH_INFO"] == ""
|
52
|
-
env.delete "CONTENT_TYPE" if env["CONTENT_TYPE"] == ""
|
53
|
-
env.delete "CONTENT_LENGTH" if env["CONTENT_LENGTH"] == ""
|
54
|
-
|
55
|
-
begin
|
56
|
-
status, headers, body = app.call(env)
|
57
|
-
begin
|
58
|
-
send_headers request.out, status, headers
|
59
|
-
send_body request.out, body
|
60
|
-
ensure
|
61
|
-
body.close if body.respond_to? :close
|
62
|
-
end
|
63
|
-
ensure
|
64
|
-
rack_input.close
|
65
|
-
request.finish
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.send_headers(out, status, headers)
|
70
|
-
out.print "Status: #{status}\r\n"
|
71
|
-
headers.each { |k, vs|
|
72
|
-
vs.split("\n").each { |v|
|
73
|
-
out.print "#{k}: #{v}\r\n"
|
74
|
-
}
|
75
|
-
}
|
76
|
-
out.print "\r\n"
|
77
|
-
out.flush
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.send_body(out, body)
|
81
|
-
body.each { |part|
|
82
|
-
out.print part
|
83
|
-
out.flush
|
84
|
-
}
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'lsapi'
|
2
|
-
require 'rack/content_length'
|
3
|
-
|
4
|
-
module Rack
|
5
|
-
module Handler
|
6
|
-
class LSWS
|
7
|
-
def self.run(app, options=nil)
|
8
|
-
while LSAPI.accept != nil
|
9
|
-
serve app
|
10
|
-
end
|
11
|
-
end
|
12
|
-
def self.serve(app)
|
13
|
-
app = Rack::ContentLength.new(app)
|
14
|
-
|
15
|
-
env = ENV.to_hash
|
16
|
-
env.delete "HTTP_CONTENT_LENGTH"
|
17
|
-
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
|
18
|
-
env.update({"rack.version" => [1,0],
|
19
|
-
"rack.input" => StringIO.new($stdin.read.to_s),
|
20
|
-
"rack.errors" => $stderr,
|
21
|
-
"rack.multithread" => false,
|
22
|
-
"rack.multiprocess" => true,
|
23
|
-
"rack.run_once" => false,
|
24
|
-
"rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
|
25
|
-
})
|
26
|
-
env["QUERY_STRING"] ||= ""
|
27
|
-
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
|
28
|
-
env["REQUEST_PATH"] ||= "/"
|
29
|
-
status, headers, body = app.call(env)
|
30
|
-
begin
|
31
|
-
send_headers status, headers
|
32
|
-
send_body body
|
33
|
-
ensure
|
34
|
-
body.close if body.respond_to? :close
|
35
|
-
end
|
36
|
-
end
|
37
|
-
def self.send_headers(status, headers)
|
38
|
-
print "Status: #{status}\r\n"
|
39
|
-
headers.each { |k, vs|
|
40
|
-
vs.split("\n").each { |v|
|
41
|
-
print "#{k}: #{v}\r\n"
|
42
|
-
}
|
43
|
-
}
|
44
|
-
print "\r\n"
|
45
|
-
STDOUT.flush
|
46
|
-
end
|
47
|
-
def self.send_body(body)
|
48
|
-
body.each { |part|
|
49
|
-
print part
|
50
|
-
STDOUT.flush
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'mongrel'
|
2
|
-
require 'stringio'
|
3
|
-
require 'rack/content_length'
|
4
|
-
require 'rack/chunked'
|
5
|
-
|
6
|
-
module Rack
|
7
|
-
module Handler
|
8
|
-
class Mongrel < ::Mongrel::HttpHandler
|
9
|
-
def self.run(app, options={})
|
10
|
-
server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0',
|
11
|
-
options[:Port] || 8080)
|
12
|
-
# Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.
|
13
|
-
# Use is similar to #run, replacing the app argument with a hash of
|
14
|
-
# { path=>app, ... } or an instance of Rack::URLMap.
|
15
|
-
if options[:map]
|
16
|
-
if app.is_a? Hash
|
17
|
-
app.each do |path, appl|
|
18
|
-
path = '/'+path unless path[0] == ?/
|
19
|
-
server.register(path, Rack::Handler::Mongrel.new(appl))
|
20
|
-
end
|
21
|
-
elsif app.is_a? URLMap
|
22
|
-
app.instance_variable_get(:@mapping).each do |(host, path, appl)|
|
23
|
-
next if !host.nil? && !options[:Host].nil? && options[:Host] != host
|
24
|
-
path = '/'+path unless path[0] == ?/
|
25
|
-
server.register(path, Rack::Handler::Mongrel.new(appl))
|
26
|
-
end
|
27
|
-
else
|
28
|
-
raise ArgumentError, "first argument should be a Hash or URLMap"
|
29
|
-
end
|
30
|
-
else
|
31
|
-
server.register('/', Rack::Handler::Mongrel.new(app))
|
32
|
-
end
|
33
|
-
yield server if block_given?
|
34
|
-
server.run.join
|
35
|
-
end
|
36
|
-
|
37
|
-
def initialize(app)
|
38
|
-
@app = Rack::Chunked.new(Rack::ContentLength.new(app))
|
39
|
-
end
|
40
|
-
|
41
|
-
def process(request, response)
|
42
|
-
env = {}.replace(request.params)
|
43
|
-
env.delete "HTTP_CONTENT_TYPE"
|
44
|
-
env.delete "HTTP_CONTENT_LENGTH"
|
45
|
-
|
46
|
-
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
|
47
|
-
|
48
|
-
env.update({"rack.version" => [1,0],
|
49
|
-
"rack.input" => request.body || StringIO.new(""),
|
50
|
-
"rack.errors" => $stderr,
|
51
|
-
|
52
|
-
"rack.multithread" => true,
|
53
|
-
"rack.multiprocess" => false, # ???
|
54
|
-
"rack.run_once" => false,
|
55
|
-
|
56
|
-
"rack.url_scheme" => "http",
|
57
|
-
})
|
58
|
-
env["QUERY_STRING"] ||= ""
|
59
|
-
env.delete "PATH_INFO" if env["PATH_INFO"] == ""
|
60
|
-
|
61
|
-
status, headers, body = @app.call(env)
|
62
|
-
|
63
|
-
begin
|
64
|
-
response.status = status.to_i
|
65
|
-
response.send_status(nil)
|
66
|
-
|
67
|
-
headers.each { |k, vs|
|
68
|
-
vs.split("\n").each { |v|
|
69
|
-
response.header[k] = v
|
70
|
-
}
|
71
|
-
}
|
72
|
-
response.send_header
|
73
|
-
|
74
|
-
body.each { |part|
|
75
|
-
response.write part
|
76
|
-
response.socket.flush
|
77
|
-
}
|
78
|
-
ensure
|
79
|
-
body.close if body.respond_to? :close
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|