Skip to content

Commit f575ddb

Browse files
committed
Use Rewindable#wrap.
1 parent f340dc8 commit f575ddb

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

async-http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
2828
spec.add_dependency "async-pool", "~> 0.7"
2929
spec.add_dependency "io-endpoint", "~> 0.11"
3030
spec.add_dependency "io-stream", "~> 0.4"
31-
spec.add_dependency "protocol-http", "~> 0.28"
31+
spec.add_dependency "protocol-http", "~> 0.29"
3232
spec.add_dependency "protocol-http1", "~> 0.20"
3333
spec.add_dependency "protocol-http2", "~> 0.18"
3434
spec.add_dependency "traces", ">= 0.10"

lib/async/http/middleware/location_redirector.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,7 @@ def call(request)
8181
# We don't want to follow redirects for HEAD requests:
8282
return super if request.head?
8383

84-
if body = request.body
85-
if body.respond_to?(:rewind)
86-
# The request body was already rewindable, so use it as is:
87-
body = request.body
88-
else
89-
# The request body was not rewindable, and we might need to resubmit it if we get a response status of 307 or 308, so make it rewindable:
90-
body = ::Protocol::HTTP::Body::Rewindable.new(body)
91-
request.body = body
92-
end
93-
end
94-
84+
body = ::Protocol::HTTP::Body::Rewindable.wrap(request)
9585
hops = 0
9686

9787
while hops <= @maximum_hops

0 commit comments

Comments
 (0)