Class: RightSpeed::Handler::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/right_speed/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



81
82
83
# File 'lib/right_speed/handler.rb', line 81

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



81
82
83
# File 'lib/right_speed/handler.rb', line 81

def headers
  @headers
end

#http_methodObject (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_versionObject (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_infoObject (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_stringObject (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_urlObject (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_styleObject



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_uriObject



94
95
96
# File 'lib/right_speed/handler.rb', line 94

def request_uri
  "http://#{@client.server_addr}:#{@client.server_port}#{request_url}"
end