-
Notifications
You must be signed in to change notification settings - Fork 125
GET to a URL with a redirection never completes nor times out #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was able to investigate a bit more. It looks like the Then the One solution could be to succeed the request in
I understand that making AHC a 3-tier library would probably make it easier to implement redirects more reliably, but it would be great to fix this for AHC v1. |
Yeah, for a redirect we probably need to consume the body entirely. |
### Motivation Currently, we don’t consume the response body of redirect responses. Because of this requests, that receive a redirect response with response body, may hang indefinitely. ### Changes - Consume redirect response body if less than 3kb - Cancel redirect response if larger than 3kb ### Result Redirect responses are consumed. Fixes swift-server#574
### Motivation Currently, we don’t consume the response body of redirect responses. Because of this requests, that receive a redirect response with response body, may hang indefinitely. ### Changes - Consume redirect response body if less than 3kb - Cancel redirect response if larger than 3kb ### Result Redirect responses are consumed. Fixes swift-server#574
### Motivation Currently, we don’t consume the response body of redirect responses. Because of this requests, that receive a redirect response with response body, may hang indefinitely. ### Changes - Consume redirect response body if less than 3kb - Cancel redirect response if larger than 3kb ### Result Redirect responses are consumed. Fixes swift-server#574
### Motivation Currently, we don’t consume the response body of redirect responses. Because of this requests, that receive a redirect response with response body, may hang indefinitely. ### Changes - Consume redirect response body if less than 3kb - Cancel redirect response if larger than 3kb ### Result Redirect responses are consumed. Fixes swift-server#574
### Motivation Currently, we don’t consume the response body of redirect responses. Because of this requests, that receive a redirect response with response body, may hang indefinitely. ### Changes - Consume redirect response body if less than 3kb - Cancel redirect response if larger than 3kb ### Result Redirect responses are consumed. Fixes #574
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I realized some requests in our backend are getting stuck, they don't complete or finish unless I set a deadline.
Upon further investigation, the requests that are getting stuck are ones with a redirect. Doing a
HEAD
instead of aGET
does result in a response (with a 301 status when disabling redirects in the client).I'm trying to use the
FileDownloadDelegate
and I also noticed that nothing is getting called (no calls to reportHead or reportProgress). But as I cannot issue a simpleGET
I guess that the issue is not in theFileDownloadDelegate
.This is some sample code that reproduces the issue:
When running that on my Mac (Xcode 13.3 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)), the request never completes.
Changing the
.GET
to a.HEAD
does make the request complete successfully.To workaround this issue, I'm creating an HTTPClient that does not follow redirects, to be able to inspect the
location
header and then use that URL on the client that downloads files.I also noticed that if you do a
HEAD
request to a URL that will perform a redirect, there seems to be no way of obtaining the redirected URL (hence having to disable redirects on the workaround client). That would also be a nice to have.Might be related to #538
The text was updated successfully, but these errors were encountered: