class Protocol::Rack::Adapter::Generic
def unwrap_request(request, env)
@parameter request [Protocol::HTTP::Request] The incoming request.
- Set `env['REMOTE_ADDR']` to the request remote adress.
- Set the `env['HTTP_X_FORWARDED_PROTO']` header to the request scheme.
- Set the `env['HTTP_HOST']` header to the request authority.
- Set the `env['CONTENT_TYPE']` and `env['CONTENT_LENGTH']` based on the incoming request body.
Process the incoming request into a valid rack `env`.
def unwrap_request(request, env) # The request protocol, either from the upgrade header or the HTTP/2 pseudo header of the same name. if protocol = request.protocol env[RACK_PROTOCOL] = protocol end if content_type = request.headers.delete("content-type") env[CGI::CONTENT_TYPE] = content_type end # In some situations we don't know the content length, e.g. when using chunked encoding, or when decompressing the body. if body = request.body and length = body.length env[CGI::CONTENT_LENGTH] = length.to_s end self.unwrap_headers(request.headers, env) # For the sake of compatibility, we set the `HTTP_UPGRADE` header to the requested protocol. if protocol = request.protocol and request.version.start_with?("HTTP/1") env[CGI::HTTP_UPGRADE] = Array(protocol).join(",") end if request.respond_to?(:hijack?) and request.hijack? env[RACK_IS_HIJACK] = true env[RACK_HIJACK] = proc{request.hijack!.io.dup} end # HTTP/2 prefers `:authority` over `host`, so we do this for backwards compatibility. env[CGI::HTTP_HOST] ||= request.authority if peer = request.peer env[CGI::REMOTE_ADDR] = peer.ip_address end end