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