(Not documented)
# File lib/rack/handler/webrick.rb, line 17 17: def initialize(server, app) 18: super server 19: @app = Rack::ContentLength.new(app) 20: end
(Not documented)
# 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: trap(:INT) { server.shutdown } 13: yield server if block_given? 14: server.start 15: end
(Not documented)
# File lib/rack/handler/webrick.rb, line 22 22: def service(req, res) 23: env = req.meta_vars 24: env.delete_if { |k, v| v.nil? } 25: 26: rack_input = StringIO.new(req.body.to_s) 27: rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding) 28: 29: env.update({"rack.version" => [1,1], 30: "rack.input" => rack_input, 31: "rack.errors" => $stderr, 32: 33: "rack.multithread" => true, 34: "rack.multiprocess" => false, 35: "rack.run_once" => false, 36: 37: "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http" 38: }) 39: 40: env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"] 41: env["QUERY_STRING"] ||= "" 42: env["REQUEST_PATH"] ||= "/" 43: unless env["PATH_INFO"] == "" 44: path, n = req.request_uri.path, env["SCRIPT_NAME"].length 45: env["PATH_INFO"] = path[n, path.length-n] 46: end 47: 48: status, headers, body = @app.call(env) 49: begin 50: res.status = status.to_i 51: headers.each { |k, vs| 52: if k.downcase == "set-cookie" 53: res.cookies.concat vs.split("\n") 54: else 55: vs.split("\n").each { |v| 56: res[k] = v 57: } 58: end 59: } 60: body.each { |part| 61: res.body << part 62: } 63: ensure 64: body.close if body.respond_to? :close 65: end 66: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.