Class Rack::Handler::LSWS
In: lib/rack/handler/lsws.rb
Parent: Object

Methods

run   send_body   send_headers   serve  

Public Class methods

[Source]

    # File lib/rack/handler/lsws.rb, line 6
 6:       def self.run(app, options=nil)
 7:         while LSAPI.accept != nil
 8:           serve app
 9:         end
10:       end

[Source]

    # File lib/rack/handler/lsws.rb, line 44
44:       def self.send_body(body)
45:         body.each { |part|
46:           print part
47:           STDOUT.flush
48:         }
49:       end

[Source]

    # File lib/rack/handler/lsws.rb, line 34
34:       def self.send_headers(status, headers)
35:         print "Status: #{status}\r\n"
36:         headers.each { |k, vs|
37:           vs.each { |v|
38:             print "#{k}: #{v}\r\n"
39:           }
40:         }
41:         print "\r\n"
42:         STDOUT.flush
43:       end

[Source]

    # File lib/rack/handler/lsws.rb, line 11
11:       def self.serve(app)
12:         env = ENV.to_hash
13:         env.delete "HTTP_CONTENT_LENGTH"
14:         env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
15:         env.update({"rack.version" => [0,1],
16:                      "rack.input" => STDIN,
17:                      "rack.errors" => STDERR,
18:                      "rack.multithread" => false,
19:                      "rack.multiprocess" => true,
20:                      "rack.run_once" => false,
21:                      "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
22:                    })
23:         env["QUERY_STRING"] ||= ""
24:         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
25:         env["REQUEST_PATH"] ||= "/"
26:         status, headers, body = app.call(env)
27:         begin
28:           send_headers status, headers
29:           send_body body
30:         ensure
31:           body.close if body.respond_to? :close
32:         end
33:       end

[Validate]