Skip to content

refactor http client #3255

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

Merged
merged 1 commit into from
Feb 11, 2021
Merged

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 11, 2021

motivation: prepare to consolidate downloader from TSC and http client from Basics

changes:

  • add progress support to "execute"
  • add authorization support to HTTPClientRequest::Options and HTTPClient::Configuration
  • refactor call-sites to use new ways
  • add and adopt tests

@tomerd
Copy link
Contributor Author

tomerd commented Feb 11, 2021

@swift-ci please smoke test

@yim-lee
Copy link
Contributor

yim-lee commented Feb 11, 2021

Compilation error on Linux only? The PR looks good overall.

@tomerd tomerd force-pushed the refactor/http-consolidaton branch 3 times, most recently from bf190d2 to c21a18a Compare February 11, 2021 06:35
motivation:
* safer handling of large responses
* prepare to consolidate Downloader from TSC and http client from Basics

changes:
* add progress support to HTTPclient::execute and URLSession based impl
* add HTTPClientRequest::Options::maxResponseSize and logic to fail the request if response is too large
* add authorization support to HTTPClientRequest::Options and HTTPClient::Configuration
* refactor call-sites to use new ways
* add and adopt tests
@tomerd tomerd force-pushed the refactor/http-consolidaton branch from c21a18a to d3500ba Compare February 11, 2021 06:46
@@ -8,28 +16,84 @@ import struct TSCUtility.Versioning
import FoundationNetworking
#endif

public struct URLSessionHTTPClient: HTTPClientProtocol {
public final class URLSessionHTTPClient: NSObject, HTTPClientProtocol {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@neonichu ptal 👀

self.underlying(
request,
{ received, expected in
if let max = request.options.maximumResponseSizeInBytes {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yim-lee this is to better support "maximumResponseSizeInBytes" at the response buffering time

@@ -275,15 +275,48 @@ class JSONPackageCollectionProviderTests: XCTestCase {
})
}

func testExceedsDownloadSizeLimitProgress() throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yim-lee 👀

@tomerd
Copy link
Contributor Author

tomerd commented Feb 11, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Feb 11, 2021

Compilation error on Linux only? The PR looks good overall.

yea seems like some of the nicer APIs are not supported on Linux, so had to do it the hard way... PR updated

@tomerd tomerd self-assigned this Feb 11, 2021
@tomerd tomerd merged commit a023bd3 into swiftlang:main Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants