Class: Reifier::Request
- Inherits:
-
Object
- Object
- Reifier::Request
- Defined in:
- lib/reifier/request.rb
Instance Attribute Summary collapse
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
-
#request_path ⇒ Object
readonly
Returns the value of attribute request_path.
-
#request_uri ⇒ Object
readonly
Returns the value of attribute request_uri.
Instance Method Summary collapse
- #handle(socket) ⇒ Object
-
#initialize(options) ⇒ Request
constructor
A new instance of Request.
- #rack_env ⇒ Object
Constructor Details
#initialize(options) ⇒ Request
5 6 7 8 |
# File 'lib/reifier/request.rb', line 5 def initialize() @body = StringIO.new('') = end |
Instance Attribute Details
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
3 4 5 |
# File 'lib/reifier/request.rb', line 3 def protocol @protocol end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
3 4 5 |
# File 'lib/reifier/request.rb', line 3 def request_method @request_method end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
3 4 5 |
# File 'lib/reifier/request.rb', line 3 def request_path @request_path end |
#request_uri ⇒ Object (readonly)
Returns the value of attribute request_uri.
3 4 5 |
# File 'lib/reifier/request.rb', line 3 def request_uri @request_uri end |
Instance Method Details
#handle(socket) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/reifier/request.rb', line 10 def handle(socket) handle_request_line(socket) handle_headers(socket) handle_body(socket) if request_with_body? end |
#rack_env ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/reifier/request.rb', line 17 def rack_env # See http://www.rubydoc.info/github/rack/rack/master/file/SPEC env = { 'rack.version' => Rack.version.split('.'), 'rack.errors' => STDERR, 'rack.multithread' => true, 'rack.multiprocess' => false, 'rack.run_once' => false, 'rack.input' => @body.set_encoding(Encoding::ASCII_8BIT), 'rack.url_scheme' => @protocol.split('/').first.downcase, 'rack.hijack?' => false, 'REQUEST_METHOD' => @request_method, 'REQUEST_PATH' => @request_path, 'REQUEST_URI' => @request_uri, 'SCRIPT_NAME' => '', 'PATH_INFO' => @request_path, 'QUERY_STRING' => @query_string, 'SERVER_PROTOCOL' => @protocol, 'SERVER_SOFTWARE' => "Reifier #{Reifier::VERSION}", 'SERVER_NAME' => [:Host], 'SERVER_PORT' => [:Port].to_s } @headers.each do |k, v| # The environment must not contain the keys HTTP_CONTENT_TYPE or HTTP_CONTENT_LENGTH (use the versions without HTTP_). # see http://www.rubydoc.info/github/rack/rack/master/file/SPEC if k == 'CONTENT_LENGTH' || k == 'CONTENT_TYPE' env[k] = v else env["HTTP_#{k}"] = v end end env end |