Class: Foobara::CommandConnectors::Http::Rack::Request

Inherits:
Http::Request
  • Object
show all
Defined in:
lib/foobara/command_connectors/http/rack/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, prefix: nil) ⇒ Request

Returns a new instance of Request.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/foobara/command_connectors/http/rack/request.rb', line 8

def initialize(env, prefix: nil)
  self.env = env

  scheme = if env["HTTP_X_FORWARDED_PROTO"] == "https" || env["HTTPS"] == "on"
             "https"
           else
             "http"
           end

  super(
    scheme:,
    host: env["SERVER_NAME"],
    port: env["SERVER_PORT"],
    path: env["PATH_INFO"],
    query_string: env["QUERY_STRING"],
    method: env["REQUEST_METHOD"],
    # TODO: should we delay this read instead of eager-loading this?
    body: env["rack.input"]&.read || "",
    headers: extract_headers,
    cookies: ::Rack::Utils.parse_cookies(env),
    remote_ip: env["REMOTE_ADDR"],
    prefix:
  )
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



6
7
8
# File 'lib/foobara/command_connectors/http/rack/request.rb', line 6

def env
  @env
end