::WEBrick::HTTPServlet::AbstractServlet
# File lib/rack/handler/webrick.rb, line 28 28: def initialize(server, app) 29: super server 30: @app = app 31: end
# File lib/rack/handler/webrick.rb, line 8 8: def self.run(app, options={}) 9: options[:BindAddress] = options.delete(:Host) if options[:Host] 10: @server = ::WEBrick::HTTPServer.new(options) 11: @server.mount "/", Rack::Handler::WEBrick, app 12: yield @server if block_given? 13: @server.start 14: end
# File lib/rack/handler/webrick.rb, line 33 33: def service(req, res) 34: env = req.meta_vars 35: env.delete_if { |k, v| v.nil? } 36: 37: rack_input = StringIO.new(req.body.to_s) 38: rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) 39: 40: env.update({"rack.version" => Rack::VERSION, 41: "rack.input" => rack_input, 42: "rack.errors" => $stderr, 43: 44: "rack.multithread" => true, 45: "rack.multiprocess" => false, 46: "rack.run_once" => false, 47: 48: "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" 49: }) 50: 51: env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] 52: env["QUERY_STRING"] ||= "" 53: unless env["PATH_INFO"] == "" 54: path, n = req.request_uri.path, env["SCRIPT_NAME"].length 55: env["PATH_INFO"] = path[n, path.length-n] 56: end 57: env["REQUEST_PATH"] ||= [env["SCRIPT_NAME"], env["PATH_INFO"]].join 58: 59: status, headers, body = @app.call(env) 60: begin 61: res.status = status.to_i 62: headers.each { |k, vs| 63: if k.downcase == "set-cookie" 64: res.cookies.concat vs.split("\n") 65: else 66: # Since WEBrick won't accept repeated headers, 67: # merge the values per RFC 1945 section 4.2. 68: res[k] = vs.split("\n").join(", ") 69: end 70: } 71: body.each { |part| 72: res.body << part 73: } 74: ensure 75: body.close if body.respond_to? :close 76: end 77: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.