[WIP] Ensure request callback is invoked on client connection error #1939
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the apparent lack of response when HTTP connections fail, such as with invalid URLs (issue #1937).
When a HTTP request is issued a
completed
delgate is supplied, which receives a booleansuccessful
parameter. This parameter is false if HTTP parsing fails or the remote connection returns an HTTP error code.If, when sending the request, a failure occurs in the connection process then the callback is never invoked. This can happen if:
And probabaly others. These failures are permanent and if notifed the application can act on them promptly. The alternative is implementing a separate timeout mechanism and just giving up.
So this PR catches a TCP error condition and invokes the request
completed
delegate with a failure code.The request remains on the waiting queue though, so the request will continue to be retried.