lib/httpx/plugins/expect.rb in httpx-0.9.0 vs lib/httpx/plugins/expect.rb in httpx-0.10.0
- old
+ new
@@ -31,15 +31,12 @@
module RequestBodyMethods
def initialize(*, options)
super
return if @body.nil?
- if (threshold = options.expect_threshold_size)
- unless unbounded_body?
- return if @body.bytesize < threshold
- end
- end
+ threshold = options.expect_threshold_size
+ return if threshold && !unbounded_body? && @body.bytesize < threshold
@headers["expect"] = "100-continue"
end
end
@@ -61,9 +58,10 @@
def fetch_response(request, connections, options)
response = @responses.delete(request)
return unless response
if response.status == 417 && request.headers.key?("expect")
+ response.close
request.headers.delete("expect")
request.transition(:idle)
connection = find_connection(request, connections, options)
connection.send(request)
return