Browse Source

Merge pull request #178 from johngibb/master

Fix curl command output
Mattt Thompson 11 years ago
parent
commit
1abaeb078b
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Source/Alamofire.swift

+ 5 - 3
Source/Alamofire.swift

@@ -1224,11 +1224,11 @@ extension Request: DebugPrintable {
             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 let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array {
                 for credential: NSURLCredential in (credentials as [NSURLCredential]) {
                 for credential: NSURLCredential in (credentials as [NSURLCredential]) {
-                    components.append("-u \(credential.user):\(credential.password)")
+                    components.append("-u \(credential.user!):\(credential.password!)")
                 }
                 }
             } else {
             } else {
                 if let credential = delegate.credential {
                 if let credential = delegate.credential {
-                    components.append("-u \(credential.user):\(credential.password)")
+                    components.append("-u \(credential.user!):\(credential.password!)")
                 }
                 }
             }
             }
         }
         }
@@ -1261,7 +1261,9 @@ extension Request: DebugPrintable {
         }
         }
         
         
         if let HTTPBody = request.HTTPBody {
         if let HTTPBody = request.HTTPBody {
-            components.append("-d \"\(NSString(data: HTTPBody, encoding: NSUTF8StringEncoding))\"")
+            let escapedBody = NSString(data: HTTPBody, encoding: NSUTF8StringEncoding)
+                                .stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
+            components.append("-d \"\(escapedBody)\"")
         }
         }
 
 
         components.append("\"\(URL.absoluteString!)\"")
         components.append("\"\(URL.absoluteString!)\"")