-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
I'm encountering an issue when using the Httpx backend where even a single redirect is not being followed:
> HTTPX::VERSION
=> "1.5.1"
> Down::VERSION
=> "5.4.2"
> url = "https://google.com" # Will redirect to https://www.google.com
> Down::Httpx.download(url)
Down::TooManyRedirects: too many redirects (Down::TooManyRedirects)
from /usr/local/bundle/gems/down-5.4.2/lib/down/httpx.rb:143:in 'Down::Httpx#response_error!'
> Down::Httpx.open(url)
Down::TooManyRedirects: too many redirects (Down::TooManyRedirects)
from /usr/local/bundle/gems/down-5.4.2/lib/down/httpx.rb:143:in 'Down::Httpx#response_error!'
> Down::Httpx.open(url, max_redirects: 42)
Down::TooManyRedirects: too many redirects (Down::TooManyRedirects)
from /usr/local/bundle/gems/down-5.4.2/lib/down/httpx.rb:143:in 'Down::Httpx#response_error!'
I believe this is because an error is raised too early while HTTPX hasn't followed a single redirect:
> stream = HTTPX.plugin(:stream).plugin(:follow_redirects).get(url, stream: true)
=> #<HTTPX::StreamResponse:76912>
> stream.status
=> 301 # This is what raises TooManyRedirects in response_error!
> stream.each { puts stream.status }
301
200
200
200
200
=> nil
The test suite appears to support my findings, I see the existing test for following redirects in Down::Httpx.open fail locally.
Here is a possible solution that fixes the test and produces expected results in the app I'm using Down in and the Rails console
#100
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels