提交 959fb5ea 编写于 作者: M Mattt Thompson

Xcode 6.1

Squashed commit of the following:

commit 6b6facc0ac407bc37e6c71f5d93d11f21894b8ba
Author: Mattt Thompson <m@mattt.me>
Date:   Fri Oct 10 05:30:58 2014 -0700

    [Issue #164] Fixed mistake in merge

commit 8a814ee8c083faf4e02189665f5b2bc6abfc0650
Merge: 0930f42 29d8b97
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Oct 9 16:01:55 2014 -0700

    Merge branch 'xcode-6.1' of github.com:Alamofire/Alamofire into xcode-6.1

    Conflicts:
    	Example/DetailViewController.swift
    	Example/MasterViewController.swift
    	Source/Alamofire.swift
    	Tests/ParameterEncodingTests.swift

commit 0930f428eb0b9d142e29a31b94a7af84f48a06e5
Merge: b1882a1 73624042
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Oct 9 15:58:36 2014 -0700

    Merge branch 'master' into xcode-6.1

    Conflicts:
    	Source/Alamofire.swift

commit 29d8b97bbc588703f5641255e5c2bcf17f58d009
Merge: 80cc057 18f1d57
Author: Mattt Thompson <mattt@users.noreply.github.com>
Date:   Sun Oct 5 09:17:17 2014 -0700

    Merge pull request #143 from nduplessis/xcode-6.1

    Xcode 6.1 GM fixes

commit 18f1d57fd8a40402c71eb85faba977ee1cd7fe01
Author: Nico du Plessis <duplessis.nico@gmail.com>
Date:   Thu Oct 2 13:13:24 2014 +0200

    Xcode 6.1 GM fixes

commit 80cc05720013042eccfc8bc20a8304cd3ae656d7
Merge: 38e0783 f8bb0b4
Author: Mattt Thompson <mattt@users.noreply.github.com>
Date:   Tue Sep 30 09:35:22 2014 -0700

    Merge pull request #139 from orta/xcode-6.1

    @mattt => update to support Xcode 6.1b3

commit f8bb0b4fb8780a5ee74098d09e9a5997f550e425
Author: Orta Therox <orta.therox@gmail.com>
Date:   Tue Sep 30 17:17:27 2014 +0100

    update to support Xcode 6.1b3

commit b1882a1d64ff4c5de8b514742f0d3a27bcf16bf1
Merge: 34ee306 bc6a58d7
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Sep 25 22:17:50 2014 -0700

    Merge branch 'master' into xcode-6.1

    Conflicts:
    	Source/Alamofire.swift
    	Tests/ParameterEncodingTests.swift

commit 38e07830df5e44b03510c2d74286e82ecebb0513
Merge: 34ee306 9933340
Author: Mattt Thompson <mattt@users.noreply.github.com>
Date:   Fri Sep 19 12:02:23 2014 -0700

    Merge pull request #114 from rosskimes/xcode-6.1

    Compiles on Xcode 6.1 Beta 2.

commit 99333407f6fa9d7476a39eb9f8f7d1d89e38afe9
Author: Ross Kimes <ross.kimes@me.com>
Date:   Fri Sep 19 13:17:02 2014 -0500

    Compiles on Xcode 6.1 Beta 2.

commit 34ee3065c98ebd19a5012f3dc03a1b5eb990d51e
Merge: 67ee13a 6c087a9
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Sep 18 07:49:27 2014 -0700

    Merge branch 'aral-patch-2' into xcode-6.1

commit 6c087a956ea2947c4de97d3e4b6c13ff06924499
Merge: 2abe348c d49bbed
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Sep 18 07:49:15 2014 -0700

    Merge branch 'patch-2' of github.com:aral/Alamofire into aral-patch-2

commit 67ee13aa14baa50f71d2583d2f3b7996224b89ba
Merge: 2abe348c ab4f4c0
Author: Mattt Thompson <m@mattt.me>
Date:   Thu Sep 18 07:48:31 2014 -0700

    Merge branch 'patch-1' of github.com:aral/Alamofire into aral-patch-1

    Conflicts:
    	Source/Alamofire.swift

commit d49bbeda306850858e5ce189380665eea9eb8ee1
Author: Aral Balkan <aral@aralbalkan.com>
Date:   Wed Sep 17 00:33:10 2014 +0100

    Replaced toRaw with rawValue (Xcode 6.1 Beta 2 update)

commit ab4f4c0fd83fc7c62018f9f19b4d54d1de107ef9
Author: Aral Balkan <aral@aralbalkan.com>
Date:   Wed Sep 17 00:31:15 2014 +0100

    Updated fromRaw and toRaw to rawValue

    Fixed for Xcode 6.1 Beta 2.
上级 dafd818a
......@@ -86,7 +86,7 @@ class DetailViewController: UITableViewController {
// MARK: UITableViewDataSource
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch Sections.fromRaw(section)! {
switch Sections(rawValue: section)! {
case .Headers:
return self.headers.count
case .Body:
......@@ -98,20 +98,20 @@ class DetailViewController: UITableViewController {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch Sections.fromRaw(indexPath.section)! {
switch Sections(rawValue: indexPath.section)! {
case .Headers:
let cell = self.tableView.dequeueReusableCellWithIdentifier("Header") as UITableViewCell
let field = self.headers.keys.array.sorted(<)[indexPath.row]
let value = self.headers[field]
cell.textLabel!.text = field
cell.textLabel.text = field
cell.detailTextLabel!.text = value
return cell
case .Body:
let cell = self.tableView.dequeueReusableCellWithIdentifier("Body") as UITableViewCell
cell.textLabel!.text = self.body
cell.textLabel.text = self.body
return cell
}
......@@ -128,7 +128,7 @@ class DetailViewController: UITableViewController {
return ""
}
switch Sections.fromRaw(section)! {
switch Sections(rawValue: section)! {
case .Headers:
return "Headers"
case .Body:
......@@ -137,7 +137,7 @@ class DetailViewController: UITableViewController {
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch Sections.fromRaw(indexPath.section)! {
switch Sections(rawValue: indexPath.section)! {
case .Body:
return 300
default:
......@@ -146,7 +146,7 @@ class DetailViewController: UITableViewController {
}
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String {
if Sections.fromRaw(section)! == .Body && self.elapsedTime != nil {
if Sections(rawValue: section)! == .Body && self.elapsedTime != nil {
let numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = .DecimalStyle
......
......@@ -32,13 +32,13 @@ enum HTTPBinRoute: URLStringConvertible {
let path: String = {
switch self {
case .Method(let method):
return "/\(method.toRaw().lowercaseString)"
return "/\(method.rawValue.lowercaseString)"
case .BasicAuth(let user, let password):
return "/basic-auth/\(user)/\(password)"
}
}()
return NSURL(string: path, relativeToURL: NSURL(string: baseURLString)).absoluteString!
return NSURL(string: path, relativeToURL: NSURL(string: baseURLString))!.absoluteString!
}
}
......@@ -52,10 +52,15 @@ class MasterViewController: UITableViewController {
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let detailViewController = segue.destinationViewController.topViewController as? DetailViewController {
func requestForSegue(segue: UIStoryboardSegue) -> Request? {
switch segue.identifier {
case "GET", "POST", "PUT", "DELETE":
let method = Alamofire.Method.fromRaw(segue.identifier)!
return Alamofire.request(method, HTTPBinRoute.Method(method))
switch segue.identifier as String! {
case "GET":
return Alamofire.request(.GET, "http://httpbin.org/get")
case "POST":
return Alamofire.request(.POST, "http://httpbin.org/post")
case "PUT":
return Alamofire.request(.PUT, "http://httpbin.org/put")
case "DELETE":
return Alamofire.request(.DELETE, "http://httpbin.org/delete")
default:
return nil
}
......
......@@ -18,9 +18,7 @@ Alamofire is an HTTP networking library written in Swift, from the [creator](htt
## Requirements
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 6.0
> For Xcode 6.1, use [the `xcode-6.1` branch](https://github.com/Alamofire/Alamofire/tree/xcode-6.1).
- Xcode 6.1
## Communication
......@@ -32,6 +30,8 @@ Alamofire is an HTTP networking library written in Swift, from the [creator](htt
## Installation
> For application targets that do not support embedded frameworks, such as iOS 7, Alamofire can be integrated by including the `Alamofire.swift` source file directly, and making the appropriate changes to calling semantics.
_Due to the current lack of [proper infrastructure](http://cocoapods.org) for Swift dependency management, using Alamofire in your project requires the following steps:_
1. Add Alamofire as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the command `git submodule add https://github.com/Alamofire/Alamofire.git`
......
......@@ -103,11 +103,12 @@ public enum ParameterEncoding {
}
}
let method = Method.fromRaw(mutableURLRequest.HTTPMethod)
let method = Method(rawValue: mutableURLRequest.HTTPMethod)
if method != nil && encodesParametersInURL(method!) {
let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false)
URLComponents.percentEncodedQuery = (URLComponents.query != nil ? URLComponents.query! + "&" : "") + query(parameters!)
mutableURLRequest.URL = URLComponents.URL
if let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false) {
URLComponents.percentEncodedQuery = (URLComponents.query != nil ? URLComponents.query! + "&" : "") + query(parameters!)
mutableURLRequest.URL = URLComponents.URL
}
} else {
if mutableURLRequest.valueForHTTPHeaderField("Content-Type") == nil {
mutableURLRequest.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
......@@ -241,18 +242,18 @@ public class Manager {
// User-Agent Header; see http://tools.ietf.org/html/rfc7231#section-5.5.3
let userAgent: String = {
let info = NSBundle.mainBundle().infoDictionary
let executable: AnyObject = info[kCFBundleExecutableKey] ?? "Unknown"
let bundle: AnyObject = info[kCFBundleIdentifierKey] ?? "Unknown"
let version: AnyObject = info[kCFBundleVersionKey] ?? "Unknown"
let os: AnyObject = NSProcessInfo.processInfo().operatingSystemVersionString ?? "Unknown"
var mutableUserAgent = NSMutableString(string: "\(executable)/\(bundle) (\(version); OS \(os))") as CFMutableString
let transform = NSString(string: "Any-Latin; Latin-ASCII; [:^ASCII:] Remove") as CFString
if CFStringTransform(mutableUserAgent, nil, transform, 0) == 1 {
return mutableUserAgent as NSString
if let info = NSBundle.mainBundle().infoDictionary {
let executable: AnyObject = info[kCFBundleExecutableKey] ?? "Unknown"
let bundle: AnyObject = info[kCFBundleIdentifierKey] ?? "Unknown"
let version: AnyObject = info[kCFBundleVersionKey] ?? "Unknown"
let os: AnyObject = NSProcessInfo.processInfo().operatingSystemVersionString ?? "Unknown"
var mutableUserAgent = NSMutableString(string: "\(executable)/\(bundle) (\(version); OS \(os))") as CFMutableString
let transform = NSString(string: "Any-Latin; Latin-ASCII; [:^ASCII:] Remove") as CFString
if CFStringTransform(mutableUserAgent, nil, transform, 0) == 1 {
return mutableUserAgent as NSString
}
}
return "Alamofire"
}()
......@@ -1235,8 +1236,8 @@ extension Request: DebugPrintable {
components.append("-X \(request.HTTPMethod!)")
}
if let credentialStorage = session.configuration.URLCredentialStorage {
let protectionSpace = NSURLProtectionSpace(host: URL.host!, port: URL.port ?? 0, `protocol`: URL.scheme, realm: URL.host, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
if let credentialStorage = self.session.configuration.URLCredentialStorage {
let protectionSpace = NSURLProtectionSpace(host: URL.host!, port: URL.port?.integerValue ?? 0, `protocol`: URL.scheme!, realm: URL.host!, authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array {
for credential: NSURLCredential in (credentials as [NSURLCredential]) {
components.append("-u \(credential.user!):\(credential.password!)")
......@@ -1276,9 +1277,9 @@ extension Request: DebugPrintable {
}
if let HTTPBody = request.HTTPBody {
let escapedBody = NSString(data: HTTPBody, encoding: NSUTF8StringEncoding)
.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
components.append("-d \"\(escapedBody)\"")
if let escapedBody = NSString(data: HTTPBody, encoding: NSUTF8StringEncoding)?.stringByReplacingOccurrencesOfString("\"", withString: "\\\"") {
components.append("-d \"\(escapedBody)\"")
}
}
components.append("\"\(URL.absoluteString!)\"")
......@@ -1438,9 +1439,9 @@ extension Request {
// MARK: - Convenience -
private func URLRequest(method: Method, URLString: URLStringConvertible) -> NSURLRequest {
let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: URLString.URLString))
mutableURLRequest.HTTPMethod = method.toRaw()
private func URLRequest(method: Method, URL: URLStringConvertible) -> NSURLRequest {
let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: URL.URLString)!)
mutableURLRequest.HTTPMethod = method.rawValue
return mutableURLRequest
}
......
......@@ -63,15 +63,18 @@ class AlamofireDownloadResponseTestCase: XCTestCase {
let contents = fileManager.contentsOfDirectoryAtURL(directory, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles, error: &fileManagerError)!
XCTAssertNil(fileManagerError, "fileManagerError should be nil")
let predicate = NSPredicate(format: "lastPathComponent = '\(numberOfLines)'")
let predicate = NSPredicate(format: "lastPathComponent = '\(numberOfLines)'")!
let filteredContents = (contents as NSArray).filteredArrayUsingPredicate(predicate)
XCTAssertEqual(filteredContents.count, 1, "should have one file in Documents")
let file = filteredContents.first as NSURL
XCTAssertEqual(file.lastPathComponent, "\(numberOfLines)", "filename should be \(numberOfLines)")
let data = NSData(contentsOfURL: file)
XCTAssertGreaterThan(data.length, 0, "data length should be non-zero")
if let data = NSData(contentsOfURL: file) {
XCTAssertGreaterThan(data.length, 0, "data length should be non-zero")
} else {
XCTFail("data should exist for contents of URL")
}
}
waitForExpectationsWithTimeout(10) { (error) in
......@@ -91,9 +94,9 @@ class AlamofireDownloadResponseTestCase: XCTestCase {
download.progress { (bytesRead, totalBytesRead, totalBytesExpectedToRead) -> Void in
expectation.fulfill()
XCTAssertGreaterThan(bytesRead, 0, "bytesRead should be > 0")
XCTAssertGreaterThan(totalBytesRead, 0, "totalBytesRead should be > 0")
XCTAssertEqual(totalBytesExpectedToRead, -1, "totalBytesExpectedToRead should be -1")
XCTAssert(bytesRead > 0, "bytesRead should be > 0")
XCTAssert(totalBytesRead > 0, "totalBytesRead should be > 0")
XCTAssert(totalBytesExpectedToRead == -1, "totalBytesExpectedToRead should be -1")
download.cancel()
}
......
......@@ -29,8 +29,8 @@ class AlamofireManagerTestCase: XCTestCase {
let manager = Alamofire.Manager()
manager.startRequestsImmediately = false
let URL = "http://httpbin.org/get"
let URLRequest = NSURLRequest(URL: NSURL(string: URL))
let URL = NSURL(string: "http://httpbin.org/get")!
let URLRequest = NSURLRequest(URL: URL)
let expectation = expectationWithDescription("\(URL)")
......
......@@ -31,7 +31,7 @@ class AlamofireURLParameterEncodingTestCase: XCTestCase {
override func setUp() {
super.setUp()
let URL = NSURL(string: "http://example.com/")
let URL = NSURL(string: "http://example.com/")!
self.URLRequest = NSURLRequest(URL: URL)
}
......@@ -52,7 +52,7 @@ class AlamofireURLParameterEncodingTestCase: XCTestCase {
func testURLParameterEncodeOneStringKeyStringValueParameterAppendedToQuery() {
var mutableURLRequest = self.URLRequest.mutableCopy() as NSMutableURLRequest
let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false)
let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false)!
URLComponents.query = "baz=qux"
mutableURLRequest.URL = URLComponents.URL
......@@ -174,7 +174,7 @@ class AlamofireURLParameterEncodingTestCase: XCTestCase {
func testURLParameterEncodeGETParametersInURL() {
var mutableURLRequest = self.URLRequest.mutableCopy() as NSMutableURLRequest
mutableURLRequest.HTTPMethod = Method.GET.toRaw()
mutableURLRequest.HTTPMethod = Method.GET.rawValue
let parameters = ["foo": 1, "bar": 2]
let (URLRequest, error) = self.encoding.encode(mutableURLRequest, parameters: parameters)
......@@ -186,12 +186,12 @@ class AlamofireURLParameterEncodingTestCase: XCTestCase {
func testURLParameterEncodePOSTParametersInHTTPBody() {
var mutableURLRequest = self.URLRequest.mutableCopy() as NSMutableURLRequest
mutableURLRequest.HTTPMethod = Method.POST.toRaw()
mutableURLRequest.HTTPMethod = Method.POST.rawValue
let parameters = ["foo": 1, "bar": 2]
let (URLRequest, error) = self.encoding.encode(mutableURLRequest, parameters: parameters)
XCTAssertEqual(NSString(data: URLRequest.HTTPBody!, encoding: NSUTF8StringEncoding), "bar=2&foo=1", "HTTPBody is incorrect")
XCTAssertEqual(NSString(data: URLRequest.HTTPBody!, encoding: NSUTF8StringEncoding)!, "bar=2&foo=1", "HTTPBody is incorrect")
XCTAssertEqual(URLRequest.valueForHTTPHeaderField("Content-Type")!, "application/x-www-form-urlencoded", "Content-Type should be application/x-www-form-urlencoded")
XCTAssertNotNil(URLRequest.HTTPBody, "HTTPBody should not be nil")
}
......@@ -204,7 +204,7 @@ class AlamofireJSONParameterEncodingTestCase: XCTestCase {
override func setUp() {
super.setUp()
let URL = NSURL(string: "http://example.com/")
let URL = NSURL(string: "http://example.com/")!
self.URLRequest = NSURLRequest(URL: URL)
}
......@@ -250,7 +250,7 @@ class AlamofirePropertyListParameterEncodingTestCase: XCTestCase {
override func setUp() {
super.setUp()
let URL = NSURL(string: "http://example.com/")
let URL = NSURL(string: "http://example.com/")!
self.URLRequest = NSURLRequest(URL: URL)
}
......@@ -322,7 +322,8 @@ class AlamofireCustomParameterEncodingTestCase: XCTestCase {
let encoding: ParameterEncoding = .Custom(encodingClosure)
let URLRequest = NSURLRequest(URL: NSURL(string: "http://example.com"))
let URL = NSURL(string: "http://example.com")!
let URLRequest = NSURLRequest(URL: URL)
let parameters: [String: AnyObject] = [:]
XCTAssertEqual(encoding.encode(URLRequest, parameters: parameters).0, encodingClosure(URLRequest, parameters).0, "URLRequest should be equal")
......
......@@ -30,7 +30,7 @@ class AlamofireRequestInitializationTestCase: XCTestCase {
let request = Alamofire.request(.GET, URL)
XCTAssertNotNil(request.request, "request should not be nil")
XCTAssertEqual(request.request.URL, NSURL(string: URL), "request URL should be equal")
XCTAssertEqual(request.request.URL, NSURL(string: URL)!, "request URL should be equal")
XCTAssertNil(request.response, "response should be nil")
}
......@@ -39,7 +39,7 @@ class AlamofireRequestInitializationTestCase: XCTestCase {
let request = Alamofire.request(.GET, URL, parameters: ["foo": "bar"])
XCTAssertNotNil(request.request, "request should not be nil")
XCTAssertNotEqual(request.request.URL, NSURL(string: URL), "request URL should be equal")
XCTAssertNotEqual(request.request.URL, NSURL(string: URL)!, "request URL should be equal")
XCTAssertEqual(request.request.URL.query!, "foo=bar", "query is incorrect")
XCTAssertNil(request.response, "response should be nil")
}
......@@ -101,9 +101,9 @@ class AlamofireRequestDebugDescriptionTestCase: XCTestCase {
let request = Alamofire.request(.GET, URL)
let components = cURLCommandComponents(request)
XCTAssertEqual(components[0..<3], ["$", "curl", "-i"])
XCTAssert(components[0..<3] == ["$", "curl", "-i"], "components should be equal")
XCTAssert(!contains(components, "-X"), "command should not contain explicit -X flag")
XCTAssertEqual(components.last!, "\"\(URL)\"")
XCTAssert(components.last! == "\"\(URL)\"", "URL component should be equal")
}
func testPOSTRequestDebugDescription() {
......@@ -111,9 +111,9 @@ class AlamofireRequestDebugDescriptionTestCase: XCTestCase {
let request = Alamofire.request(.POST, URL)
let components = cURLCommandComponents(request)
XCTAssertEqual(components[0..<3], ["$", "curl", "-i"])
XCTAssertEqual(components[3..<5], ["-X", "POST"])
XCTAssertEqual(components.last!, "\"\(URL)\"")
XCTAssert(components[0..<3] == ["$", "curl", "-i"], "components should be equal")
XCTAssert(components[3..<5] == ["-X", "POST"], "command should contain explicit -X flag")
XCTAssert(components.last! == "\"\(URL)\"", "URL component should be equal")
}
func testPOSTRequestWithJSONParametersDebugDescription() {
......@@ -121,10 +121,10 @@ class AlamofireRequestDebugDescriptionTestCase: XCTestCase {
let request = Alamofire.request(.POST, URL, parameters: ["foo": "bar"], encoding: .JSON)
let components = cURLCommandComponents(request)
XCTAssertEqual(components[0..<3], ["$", "curl", "-i"])
XCTAssertEqual(components[3..<5], ["-X", "POST"])
XCTAssert(components[0..<3] == ["$", "curl", "-i"], "components should be equal")
XCTAssert(components[3..<5] == ["-X", "POST"], "command should contain explicit -X flag")
XCTAssert(request.debugDescription.rangeOfString("-H \"Content-Type: application/json\"") != nil)
XCTAssert(request.debugDescription.rangeOfString("-d \"{\"foo\":\"bar\"}\"") != nil)
XCTAssertEqual(components.last!, "\"\(URL)\"")
XCTAssert(request.debugDescription.rangeOfString("-d \"{\\\"foo\\\":\\\"bar\\\"}\"") != nil)
XCTAssert(components.last! == "\"\(URL)\"", "URL component should be equal")
}
}
......@@ -55,9 +55,9 @@ class UploadResponseTestCase: XCTestCase {
upload.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) -> Void in
expectation.fulfill()
XCTAssertGreaterThan(bytesWritten, 0, "bytesWritten should be > 0")
XCTAssertGreaterThan(totalBytesWritten, 0, "totalBytesWritten should be > 0")
XCTAssertGreaterThan(totalBytesExpectedToWrite, 0, "totalBytesExpectedToWrite should be > 0")
XCTAssert(bytesWritten > 0, "bytesWritten should be > 0")
XCTAssert(totalBytesWritten > 0, "totalBytesWritten should be > 0")
XCTAssert(totalBytesExpectedToWrite > 0, "totalBytesExpectedToWrite should be > 0")
upload.cancel()
}
......
......@@ -203,7 +203,7 @@ class AlamofireMultipleValidationTestCase: XCTestCase {
class AlamofireAutomaticValidationTestCase: XCTestCase {
func testValidationForRequestWithAcceptableStatusCodeAndContentTypeResponse() {
let URL = NSURL(string: "http://httpbin.org/ip")
let URL = NSURL(string: "http://httpbin.org/ip")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Accept")
......@@ -243,7 +243,7 @@ class AlamofireAutomaticValidationTestCase: XCTestCase {
func testValidationForRequestWithAcceptableWildcardContentTypeResponse() {
let URL = NSURL(string: "http://httpbin.org/ip")
let URL = NSURL(string: "http://httpbin.org/ip")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.setValue("application/*", forHTTPHeaderField: "Accept")
......@@ -263,7 +263,7 @@ class AlamofireAutomaticValidationTestCase: XCTestCase {
}
func testValidationForRequestWithAcceptableComplexContentTypeResponse() {
let URL = NSURL(string: "http://httpbin.org/xml")
let URL = NSURL(string: "http://httpbin.org/xml")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.setValue("text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8,*/*;q=0.5", forHTTPHeaderField: "Accept")
......@@ -283,7 +283,7 @@ class AlamofireAutomaticValidationTestCase: XCTestCase {
}
func testValidationForRequestWithUnacceptableContentTypeResponse() {
let URL = NSURL(string: "http://httpbin.org/xml")
let URL = NSURL(string: "http://httpbin.org/xml")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Accept")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册