24: def process_requestprocess_requestprocess_request(request, input_body, socket)
25: env = {}.replace(request)
26: env.delete "HTTP_CONTENT_TYPE"
27: env.delete "HTTP_CONTENT_LENGTH"
28: env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2)
29: env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
30: env["PATH_INFO"] = env["REQUEST_PATH"]
31: env["QUERY_STRING"] ||= ""
32: env["SCRIPT_NAME"] = ""
33: env.update({"rack.version" => [0,1],
34: "rack.input" => StringIO.new(input_body),
35: "rack.errors" => STDERR,
36:
37: "rack.multithread" => true,
38: "rack.multiprocess" => true,
39: "rack.run_once" => false,
40:
41: "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
42: })
43: status, headers, body = app.call(env)
44: begin
45: socket.write("Status: #{status}\r\n")
46: headers.each do |k, vs|
47: vs.each {|v| socket.write("#{k}: #{v}\r\n")}
48: end
49: socket.write("\r\n")
50: body.each {|s| socket.write(s)}
51: ensure
52: body.close if body.respond_to? :close
53: end
54: end