Skip to content

Conversation

@dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Apr 12, 2023

Motivation

If the HTTP response status is not 2xx or the file being downloaded becomes too big, it is desirable to cancel the file download eagerly. This is currently quite hard because the reportHead and reportProgress closures do not have direct access to the HTTPClient.Task.

Modifications

  • Pass HTTPClient.Task additionally to reportHead and reportProgress closures

Result

A file download can now easily be cancelled at any time.

…tProgress` closures

### Motivation
If the HTTP response status is not 2xx or the file being downloaded becomes too big, it is desirable to cancel the file download eagerly. This is currently quite hard because the `reportHead` and `reportProgress` closures do not have direct access to the `HTTPClient.Task`.

### Modifications
- Pass `HTTPClient.Task` additionally to `reportHead` and `reportProgress` closures

### Result
A file download can now easily be cancelled at any time.
@dnadoba dnadoba added the 🆕 semver/minor Adds new public API. label Apr 12, 2023
@dnadoba dnadoba requested a review from MaxDesiatov April 12, 2023 18:27
Copy link
Member

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a quite more elegant solution. Much appreciated!

@Lukasa Lukasa merged commit 45626d3 into swift-server:main Apr 13, 2023
@dnadoba dnadoba deleted the dn-forward-request-task branch April 13, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants