mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
98b45ed1cd
Sometimes it can be useful to connect to one host e.g. `x.example.com` but request and validate the certificate chain as if we would connect to `y.example.com`. This is what this PR adds support for by adding a `dnsOverride` configuration to `HTTPClient.Configuration`. This is similar to curls `—resolve-to` option but only allows overriding host and not ports for now.
37 lines
1.1 KiB
Swift
37 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the AsyncHTTPClient open source project
|
|
//
|
|
// Copyright (c) 2021 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import NIOCore
|
|
|
|
struct RequestOptions {
|
|
/// The maximal `TimeAmount` that is allowed to pass between `channelRead`s from the Channel.
|
|
var idleReadTimeout: TimeAmount?
|
|
|
|
var dnsOverride: [String: String]
|
|
|
|
init(idleReadTimeout: TimeAmount?, dnsOverride: [String: String]) {
|
|
self.idleReadTimeout = idleReadTimeout
|
|
self.dnsOverride = dnsOverride
|
|
}
|
|
}
|
|
|
|
extension RequestOptions {
|
|
static func fromClientConfiguration(_ configuration: HTTPClient.Configuration) -> Self {
|
|
RequestOptions(
|
|
idleReadTimeout: configuration.timeout.read,
|
|
dnsOverride: configuration.dnsOverride
|
|
)
|
|
}
|
|
}
|