|
|
@@ -70,8 +70,8 @@ public enum ParameterEncoding {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if encodesParametersInURL(Method.fromRaw(request.HTTPMethod)!) {
|
|
|
- let URLComponents = NSURLComponents(URL: mutableRequest.URL, resolvingAgainstBaseURL: false)
|
|
|
+ if encodesParametersInURL(Method.fromRaw(request.HTTPMethod!)!) {
|
|
|
+ let URLComponents = NSURLComponents(URL: mutableRequest.URL!, resolvingAgainstBaseURL: false)
|
|
|
URLComponents.query = (URLComponents.query != nil ? URLComponents.query! + "&" : "") + query(parameters!)
|
|
|
mutableRequest.URL = URLComponents.URL
|
|
|
} else {
|
|
|
@@ -335,7 +335,7 @@ public class Manager {
|
|
|
|
|
|
// MARK: NSURLSessionDownloadDelegate
|
|
|
|
|
|
- func URLSession(session: NSURLSession!, downloadTask: NSURLSessionDownloadTask!, didFinishDownloadingToURL location: NSURL!) {
|
|
|
+ func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
|
|
|
if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate {
|
|
|
delegate.URLSession(session, downloadTask: downloadTask, didFinishDownloadingToURL: location)
|
|
|
}
|
|
|
@@ -343,7 +343,7 @@ public class Manager {
|
|
|
self.downloadTaskDidFinishDownloadingToURL?(session, downloadTask, location)
|
|
|
}
|
|
|
|
|
|
- func URLSession(session: NSURLSession!, downloadTask: NSURLSessionDownloadTask!, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
|
|
|
+ func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
|
|
|
if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate {
|
|
|
delegate.URLSession(session, downloadTask: downloadTask, didWriteData: bytesWritten, totalBytesWritten: totalBytesWritten, totalBytesExpectedToWrite: totalBytesExpectedToWrite)
|
|
|
}
|
|
|
@@ -351,7 +351,7 @@ public class Manager {
|
|
|
self.downloadTaskDidWriteData?(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite)
|
|
|
}
|
|
|
|
|
|
- func URLSession(session: NSURLSession!, downloadTask: NSURLSessionDownloadTask!, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
|
|
|
+ func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
|
|
|
if let delegate = self[downloadTask] as? Request.DownloadTaskDelegate {
|
|
|
delegate.URLSession(session, downloadTask: downloadTask, didResumeAtOffset: fileOffset, expectedTotalBytes: expectedTotalBytes)
|
|
|
}
|
|
|
@@ -412,13 +412,13 @@ public class Request {
|
|
|
|
|
|
public func authenticate(HTTPBasic user: String, password: String) -> Self {
|
|
|
let credential = NSURLCredential(user: user, password: password, persistence: .ForSession)
|
|
|
- let protectionSpace = NSURLProtectionSpace(host: self.request.URL.host, port: 0, `protocol`: self.request.URL.scheme, realm: nil, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
|
|
|
+ let protectionSpace = NSURLProtectionSpace(host: self.request.URL.host!, port: 0, `protocol`: self.request.URL.scheme, realm: nil, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
|
|
|
|
|
|
return authenticate(usingCredential: credential, forProtectionSpace: protectionSpace)
|
|
|
}
|
|
|
|
|
|
public func authenticate(usingCredential credential: NSURLCredential, forProtectionSpace protectionSpace: NSURLProtectionSpace) -> Self {
|
|
|
- self.session.configuration.URLCredentialStorage.setCredential(credential, forProtectionSpace: protectionSpace)
|
|
|
+ self.session.configuration.URLCredentialStorage?.setCredential(credential, forProtectionSpace: protectionSpace)
|
|
|
|
|
|
return self
|
|
|
}
|
|
|
@@ -727,7 +727,7 @@ extension Request {
|
|
|
|
|
|
return { (temporaryURL, response) -> (NSURL) in
|
|
|
if let directoryURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
|
|
|
- return directoryURL.URLByAppendingPathComponent(response.suggestedFilename)
|
|
|
+ return directoryURL.URLByAppendingPathComponent(response.suggestedFilename!)
|
|
|
}
|
|
|
|
|
|
return temporaryURL
|
|
|
@@ -747,7 +747,7 @@ extension Request {
|
|
|
|
|
|
// MARK: NSURLSessionDownloadDelegate
|
|
|
|
|
|
- func URLSession(session: NSURLSession!, downloadTask: NSURLSessionDownloadTask!, didFinishDownloadingToURL location: NSURL!) {
|
|
|
+ func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
|
|
|
if self.downloadTaskDidFinishDownloadingToURL != nil {
|
|
|
let destination = self.downloadTaskDidFinishDownloadingToURL!(session, downloadTask, location)
|
|
|
var fileManagerError: NSError?
|
|
|
@@ -792,14 +792,14 @@ extension Request: DebugPrintable {
|
|
|
func cURLRepresentation() -> String {
|
|
|
var components: [String] = ["$ curl -i"]
|
|
|
|
|
|
- let URL = self.request.URL!
|
|
|
+ let URL = self.request.URL
|
|
|
|
|
|
if self.request.HTTPMethod != "GET" {
|
|
|
components.append("-X \(self.request.HTTPMethod)")
|
|
|
}
|
|
|
|
|
|
if let credentialStorage = self.session.configuration.URLCredentialStorage {
|
|
|
- let protectionSpace = NSURLProtectionSpace(host: URL.host, port: URL.port ?? 0, `protocol`: URL.scheme, realm: URL.host, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
|
|
|
+ let protectionSpace = NSURLProtectionSpace(host: URL.host!, port: URL.port ?? 0, `protocol`: URL.scheme, realm: URL.host, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
|
|
|
if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array {
|
|
|
if !credentials.isEmpty {
|
|
|
if let credential = credentials[0] as? NSURLCredential {
|
|
|
@@ -818,7 +818,7 @@ extension Request: DebugPrintable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (field, value) in self.request.allHTTPHeaderFields {
|
|
|
+ for (field, value) in self.request.allHTTPHeaderFields! {
|
|
|
switch field {
|
|
|
case "Cookie":
|
|
|
continue
|