Skip to content

Commit

Permalink
Move response_hijack code into else clause
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Feb 3, 2023
1 parent fbf313d commit d87d3bf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/puma/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ def prepare_response(status, headers, res_body, requests, client)
resp_info = str_headers(env, status, headers, res_body, io_buffer, force_keep_alive)

close_body = false
response_hijack = nil
content_length = resp_info[:content_length]
keep_alive = resp_info[:keep_alive]

if res_body.respond_to? :each
if res_body.respond_to?(:each) && !resp_info[:response_hijack]
# below converts app_body into body, dependent on app_body's characteristics, and
# resp_info[:content_length] will be set if it can be determined
if !content_length && !resp_info[:transfer_encoding] && status != 204
Expand Down Expand Up @@ -208,16 +209,15 @@ def prepare_response(status, headers, res_body, requests, client)
else
body = res_body
end
else
# partial hijack, from Rack spec:
# Servers must ignore the body part of the response tuple when the
# rack.hijack response header is present.
response_hijack = resp_info[:response_hijack] || res_body
end

line_ending = LINE_END

if res_body && !res_body.respond_to?(:each)
response_hijack = res_body
else
response_hijack = resp_info[:response_hijack]
end

cork_socket socket

if resp_info[:no_body]
Expand Down

0 comments on commit d87d3bf

Please sign in to comment.