Class: RightSpeed::Handler::Request
- Inherits:
-
Object
- Object
- RightSpeed::Handler::Request
- Defined in:
- lib/right_speed/handler.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
-
#http_version ⇒ Object
readonly
Returns the value of attribute http_version.
-
#path_info ⇒ Object
readonly
Returns the value of attribute path_info.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
-
#request_url ⇒ Object
readonly
Returns the value of attribute request_url.
Instance Method Summary collapse
- #headers_in_env_style ⇒ Object
-
#initialize(client:, http_method:, http_version:, request_url:, headers:, body:) ⇒ Request
constructor
A new instance of Request.
- #request_uri ⇒ Object
Constructor Details
#initialize(client:, http_method:, http_version:, request_url:, headers:, body:) ⇒ Request
Returns a new instance of Request.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/right_speed/handler.rb', line 83 def initialize(client:, http_method:, http_version:, request_url:, headers:, body:) @client = client @http_method = http_method @http_version = "HTTP/" + http_version.map(&:to_s).join(".") @request_url = request_url @headers = headers @body = StringIO.new(body) @path_info, @query_string = request_url.split('?') end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def headers @headers end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def http_method @http_method end |
#http_version ⇒ Object (readonly)
Returns the value of attribute http_version.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def http_version @http_version end |
#path_info ⇒ Object (readonly)
Returns the value of attribute path_info.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def path_info @path_info end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def query_string @query_string end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
81 82 83 |
# File 'lib/right_speed/handler.rb', line 81 def request_url @request_url end |
Instance Method Details
#headers_in_env_style ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/right_speed/handler.rb', line 98 def headers_in_env_style headers = {} @headers.each do |key, value| headers["HTTP_" + key.gsub("-", "_").upcase] = value end headers end |
#request_uri ⇒ Object
94 95 96 |
# File 'lib/right_speed/handler.rb', line 94 def request_uri "http://#{@client.server_addr}:#{@client.server_port}#{request_url}" end |