Created
November 7, 2015 09:14
-
-
Save takaheraw/2cc780aca4f4f1fa58e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func getHeader(header:String) { | |
let url = NSURL(string: "http://www.apress.com") | |
let request = NSURLRequest(URL: url!) | |
NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { data, response, error in | |
if let httpResponse = response as? NSHTTPURLResponse { | |
if let headerValue = httpResponse.allHeaderFields[header] as? NSString { | |
print("\(header): \(headerValue)") | |
} | |
} | |
}).resume() | |
} | |
let headers = ["Content-Length", "Content-Encoding"] | |
for header in headers { | |
getHeader(header) | |
} | |
NSFileHandle.fileHandleWithStandardInput().availableData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment