Last active
January 10, 2017 14:25
-
-
Save roccozanni/e8633a06bc802bb3e4080d36fb7d90f5 to your computer and use it in GitHub Desktop.
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
// Create http request | |
let message = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET", self.url, kCFHTTPVersion1_1).takeRetainedValue() | |
// Create stream | |
let readStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, message).takeRetainedValue() | |
// Set stream properties | |
CFReadStreamSetProperty(readStream, NSStreamNetworkServiceTypeBackground, NSStreamNetworkServiceTypeBackground) | |
CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPShouldAutoredirect, kCFBooleanTrue) | |
// Configure proxy | |
if let proxySettings = CFNetworkCopySystemProxySettings()?.takeRetainedValue() { | |
CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxySettings) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment