revert deactivation of expect when receiving an 100 response

This commit is contained in:
HoneyryderChuck 2021-01-12 12:43:31 +00:00
parent 2f210d81e1
commit 32eebe6d9d

View File

@ -38,6 +38,23 @@ module HTTPX
@headers["expect"] = "100-continue"
end
def response=(response)
super
return unless @response && @response == 100 &&
!@request.headers.key?("expect") &&
(@state == :body || @state == :done)
# if we're past this point, this means that we just received a 100-Continue response,
# but the request doesn't have the expect flag, and is already flushing (or flushed) the body.
#
# this means that expect was deactivated for this request too soon, i.e. response took longer.
#
# so we have to reactivate it again.
request.headers["expect"] = "100-continue"
@response = nil
end
end
module ConnectionMethods