lib/falcon/adapters/rack.rb in falcon-0.22.3 vs lib/falcon/adapters/rack.rb in falcon-0.23.0

- old
+ new

@@ -53,11 +53,14 @@ RACK_RUNONCE = 'rack.run_once'.freeze RACK_URL_SCHEME = 'rack.url_scheme'.freeze RACK_HIJACK = 'rack.hijack'.freeze RACK_IS_HIJACK = 'rack.hijack?'.freeze RACK_HIJACK_IO = 'rack.hijack_io'.freeze + RACK_EARLY_HINTS = "rack.early_hints".freeze + ASYNC_HTTP_REQUEST = "async.http.request".freeze + # Header constants HTTP_X_FORWARDED_PROTO = 'HTTP_X_FORWARDED_PROTO'.freeze def initialize(app, logger = Async.logger) @app = app @@ -118,10 +121,12 @@ server_name, server_port = (request.authority || '').split(':', 2) env = { RACK_VERSION => [2, 0, 0], + ASYNC_HTTP_REQUEST => request, + RACK_INPUT => Input.new(request.body), RACK_ERRORS => $stderr, RACK_LOGGER => Async.logger, RACK_MULTITHREAD => true, @@ -152,9 +157,17 @@ SERVER_NAME => server_name || '', SERVER_PORT => server_port || '', } self.unwrap_request(request, env) + + if request.push? + env[RACK_EARLY_HINTS] = lambda do |headers| + Falcon::Adapters::Push.early_hints(headers) do |path| + request.push(path) + end + end + end if request.hijack? env[RACK_IS_HIJACK] = true env[RACK_HIJACK] = lambda do