Skip to content

refactor proxy configuration #90

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 2 commits into from
Aug 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/AsyncHTTPClient/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public class HTTPClient {
}
}

private func resolveAddress(request: Request, proxy: Proxy?) -> (host: String, port: Int) {
private func resolveAddress(request: Request, proxy: Configuration.Proxy?) -> (host: String, port: Int) {
switch self.configuration.proxy {
case .none:
return (request.host, request.port)
Expand Down
34 changes: 21 additions & 13 deletions Sources/AsyncHTTPClient/HTTPClientProxyHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down