Skip to content

GET to a URL with a redirection never completes nor times out #574

Closed
@0xpablo

Description

@0xpablo

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 a GET 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 simple GET I guess that the issue is not in the FileDownloadDelegate.

This is some sample code that reproduces the issue:

import AsyncHTTPClient

let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)

let url = "https://ipfs.infura.io/ipfs/QmVES23Brg2HP2Cn5AEzkiToYpAPxvYfXrHbrg91ScLUES/image.jpeg"

let response = try httpClient.execute(request: .init(url: url, method: .GET)).wait()

print(response)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugFeature doesn't work as expected.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions