mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
refactor proxy configuration (#90)
* refactor proxy configuration motivation: make proxy configuration follow same convention as other configuration changes: * nest Proxy under HTTPClient.Configuration instad of top level HTTPClient * make host and port public and mutable, following convention of other configuration objects in this library * add some API docs * fixup
This commit is contained in:
committed by
Artem Redkin
parent
8814439abe
commit
b1eb92eb3d
@@ -15,20 +15,28 @@
|
||||
import NIO
|
||||
import NIOHTTP1
|
||||
|
||||
/// Specifies the remote address of an HTTP proxy.
|
||||
///
|
||||
/// Adding an `HTTPClientProxy` to your client's `HTTPClient.Configuration`
|
||||
/// will cause requests to be passed through the specified proxy using the
|
||||
/// HTTP `CONNECT` method.
|
||||
///
|
||||
/// If a `TLSConfiguration` is used in conjunction with `HTTPClientProxy`,
|
||||
/// TLS will be established _after_ successful proxy, between your client
|
||||
/// and the destination server.
|
||||
public extension HTTPClient {
|
||||
public extension HTTPClient.Configuration {
|
||||
/// Proxy server configuration
|
||||
/// Specifies the remote address of an HTTP proxy.
|
||||
///
|
||||
/// Adding an `Proxy` to your client's `HTTPClient.Configuration`
|
||||
/// will cause requests to be passed through the specified proxy using the
|
||||
/// HTTP `CONNECT` method.
|
||||
///
|
||||
/// If a `TLSConfiguration` is used in conjunction with `HTTPClient.Configuration.Proxy`,
|
||||
/// TLS will be established _after_ successful proxy, between your client
|
||||
/// and the destination server.
|
||||
struct Proxy {
|
||||
internal let host: String
|
||||
internal let port: Int
|
||||
/// Specifies Proxy server host.
|
||||
public var host: String
|
||||
/// Specifies Proxy server port.
|
||||
public var port: Int
|
||||
|
||||
/// Create proxy.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - host: proxy server host.
|
||||
/// - port: proxy server port.
|
||||
public static func server(host: String, port: Int) -> Proxy {
|
||||
return .init(host: host, port: port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user