Skip to content

Instantly share code, notes, and snippets.

@OliverLetterer
Created March 4, 2020 14:25
Show Gist options
  • Save OliverLetterer/b0e06abc57307d372a412c16cc8c2090 to your computer and use it in GitHub Desktop.
Save OliverLetterer/b0e06abc57307d372a412c16cc8c2090 to your computer and use it in GitHub Desktop.
import Alamofire
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData
let proxyConfiguration: [AnyHashable : Any] = [
kCFNetworkProxiesHTTPEnable as AnyHashable: true,
kCFNetworkProxiesHTTPProxy as AnyHashable: host,
kCFNetworkProxiesHTTPPort as AnyHashable: port,
kCFStreamPropertyHTTPSProxyHost as AnyHashable: host,
kCFStreamPropertyHTTPSProxyPort as AnyHashable: port,
kCFProxyUsernameKey as AnyHashable: username,
kCFProxyPasswordKey as AnyHashable: password,
]
configuration.httpAdditionalHeaders = [
"Proxy-Authorization": HTTPHeader.authorization(username: username, password: password).value
]
configuration.connectionProxyDictionary = proxyConfiguration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment