Skip to content

Commit

Permalink
Use Rewindable#wrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 28, 2024
1 parent f340dc8 commit f575ddb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion async-http.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "async-pool", "~> 0.7"
spec.add_dependency "io-endpoint", "~> 0.11"
spec.add_dependency "io-stream", "~> 0.4"
spec.add_dependency "protocol-http", "~> 0.28"
spec.add_dependency "protocol-http", "~> 0.29"
spec.add_dependency "protocol-http1", "~> 0.20"
spec.add_dependency "protocol-http2", "~> 0.18"
spec.add_dependency "traces", ">= 0.10"
Expand Down
12 changes: 1 addition & 11 deletions lib/async/http/middleware/location_redirector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,7 @@ def call(request)
# We don't want to follow redirects for HEAD requests:
return super if request.head?

if body = request.body
if body.respond_to?(:rewind)
# The request body was already rewindable, so use it as is:
body = request.body
else
# 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:
body = ::Protocol::HTTP::Body::Rewindable.new(body)
request.body = body
end
end

body = ::Protocol::HTTP::Body::Rewindable.wrap(request)
hops = 0

while hops <= @maximum_hops
Expand Down

0 comments on commit f575ddb

Please sign in to comment.