Skip to content

HTTPClient should fail early if the internet connection is offline or disconnects #826

Open
@gregcotten

Description

@gregcotten

Another big bump in a transition from URLSession to HTTPClient:

HTTPClient has no way of knowing the internet is offline or is disconnected. An executed request that hasn't connected will just result in a connection timeout, and a connected request that becomes disconnected during read/write will result in a read/write timeout, which with the shared singleton configuration is 90 seconds (!!!).

As a comparison, URLSession's default configuration causes a request to fail immediately with NSURLErrorNotConnectedToInternet unless waitsForConnectivity is set to true, in which case it then waits the full timeoutIntervalForRequest before failing, equivalent to AHC's Timeout.connect. No matter what waitsForConnectivity is set to, a disconnection from the internet during a connected request's read/write results in an immediate failure with NSURLErrorNetworkConnectionLost

I think URLSession's default behavior is quite sensible, and it would be great to offer an equivalent in AHC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions