Sha256: 3283f8b9f8a22d026c9c952f94af17eb8d46edb94b83dece98f6216ef774b2c6

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Foobara
  module CommandConnectors
    class Http < Foobara::CommandConnector
      class Rack < Http
        class Request < Http::Request
          attr_accessor :env

          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: env.select { |s| s.start_with?("HTTP_") },
              cookies: env["HTTP_COOKIE"],
              remote_ip: env["REMOTE_ADDR"],
              prefix:
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foobara-rack-connector-0.0.3 lib/foobara/command_connectors/http/rack/request.rb