Parent

Methods

Class Index [+]

Quicksearch

Rack::Handler::WEBrick

Public Class Methods

new(server, app) click to toggle source

(Not documented)

    # File lib/rack/handler/webrick.rb, line 16
16:       def initialize(server, app)
17:         super server
18:         @app = Rack::ContentLength.new(app)
19:       end
run(app, options={}) click to toggle source

(Not documented)

    # File lib/rack/handler/webrick.rb, line 8
 8:       def self.run(app, options={})
 9:         server = ::WEBrick::HTTPServer.new(options)
10:         server.mount "/", Rack::Handler::WEBrick, app
11:         trap(:INT) { server.shutdown }
12:         yield server  if block_given?
13:         server.start
14:       end

Public Instance Methods

service(req, res) click to toggle source

(Not documented)

    # File lib/rack/handler/webrick.rb, line 21
21:       def service(req, res)
22:         env = req.meta_vars
23:         env.delete_if { |k, v| v.nil? }
24: 
25:         env.update({"rack.version" => [0,1],
26:                      "rack.input" => StringIO.new(req.body.to_s),
27:                      "rack.errors" => $stderr,
28: 
29:                      "rack.multithread" => true,
30:                      "rack.multiprocess" => false,
31:                      "rack.run_once" => false,
32: 
33:                      "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
34:                    })
35: 
36:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
37:         env["QUERY_STRING"] ||= ""
38:         env["REQUEST_PATH"] ||= "/"
39:         if env["PATH_INFO"] == ""
40:           env.delete "PATH_INFO"
41:         else
42:           path, n = req.request_uri.path, env["SCRIPT_NAME"].length
43:           env["PATH_INFO"] = path[n, path.length-n]
44:         end
45: 
46:         status, headers, body = @app.call(env)
47:         begin
48:           res.status = status.to_i
49:           headers.each { |k, vs|
50:             if k.downcase == "set-cookie"
51:               res.cookies.concat vs.split("\n")
52:             else
53:               vs.split("\n").each { |v|
54:                 res[k] = v
55:               }
56:             end
57:           }
58:           body.each { |part|
59:             res.body << part
60:           }
61:         ensure
62:           body.close  if body.respond_to? :close
63:         end
64:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.