-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTPClient.shared a globally shared singleton & .browserLike configur…
…ation (#705) Co-authored-by: Johannes Weiss <[email protected]>
- Loading branch information
Showing
6 changed files
with
138 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the AsyncHTTPClient open source project | ||
// | ||
// Copyright (c) 2023 Apple Inc. and the AsyncHTTPClient project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
extension HTTPClient.Configuration { | ||
/// The ``HTTPClient/Configuration`` for ``HTTPClient/shared`` which tries to mimic the platform's default or prevalent browser as closely as possible. | ||
/// | ||
/// Don't rely on specific values of this configuration as they're subject to change. You can rely on them being somewhat sensible though. | ||
/// | ||
/// - note: At present, this configuration is nowhere close to a real browser configuration but in case of disagreements we will choose values that match | ||
/// the default browser as closely as possible. | ||
/// | ||
/// Platform's default/prevalent browsers that we're trying to match (these might change over time): | ||
/// - macOS: Safari | ||
/// - iOS: Safari | ||
/// - Android: Google Chrome | ||
/// - Linux (non-Android): Google Chrome | ||
public static var singletonConfiguration: HTTPClient.Configuration { | ||
// To start with, let's go with these values. Obtained from Firefox's config. | ||
return HTTPClient.Configuration( | ||
certificateVerification: .fullVerification, | ||
redirectConfiguration: .follow(max: 20, allowCycles: false), | ||
timeout: Timeout(connect: .seconds(90), read: .seconds(90)), | ||
connectionPool: .seconds(600), | ||
proxy: nil, | ||
ignoreUncleanSSLShutdown: false, | ||
decompression: .enabled(limit: .ratio(10)), | ||
backgroundActivityLogger: nil | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.