class Falcon::Adapters::Rack
def unwrap_request(request, env)
def unwrap_request(request, env) if content_type = request.headers.delete('content-type') env[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[CONTENT_LENGTH] = length.to_s end self.unwrap_headers(request.headers, env) # HTTP/2 prefers `:authority` over `host`, so we do this for backwards compatibility. env[HTTP_HOST] ||= request.authority # This is the HTTP/1 header for the scheme of the request and is used by Rack. # Technically it should use the Forwarded header but this is not common yet. # https://tools.ietf.org/html/rfc7239#section-5.4 # https://github.com/rack/rack/issues/1310 env[HTTP_X_FORWARDED_PROTO] ||= request.scheme if remote_address = request.remote_address env[REMOTE_ADDR] = remote_address.ip_address if remote_address.ip? end end