lib/pitchfork/chunked.rb in pitchfork-0.14.0 vs lib/pitchfork/chunked.rb in pitchfork-0.15.0
- old
+ new
@@ -102,15 +102,18 @@
# but does not have content-length or transfer-encoding headers,
# modify the response to use chunked transfer-encoding.
def call(env)
status, headers, body = response = @app.call(env)
- if chunkable_version?(env[Rack::SERVER_PROTOCOL]) &&
+ if !env.key?('rack.hijack_io') && # full highjack
+ !headers['rack.hijack'] && # partial hijack
+ body.respond_to?(:each) && # body must be enumerable (i.e. non-streaming)
+ chunkable_version?(env[Rack::SERVER_PROTOCOL]) &&
!STATUS_WITH_NO_ENTITY_BODY.key?(status.to_i) &&
!headers[Rack::CONTENT_LENGTH] &&
- !headers[Rack::TRANSFER_ENCODING]
+ !headers["transfer-encoding"]
- headers[Rack::TRANSFER_ENCODING] = 'chunked'
+ headers["transfer-encoding"] = 'chunked'
if headers['trailer']
response[2] = TrailerBody.new(body)
else
response[2] = Body.new(body)
end