Skip to content

Commit 05d1b6b

Browse files
author
Pushkar N Kulkarni
committed
Changing the NSHTTPCookie API to match the Darwin version
1 parent 6488630 commit 05d1b6b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Foundation/NSHTTPCookie.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ public class NSHTTPCookie : NSObject {
367367
*/
368368

369369
/*!
370-
@method requestHeaderFieldsWithCookies:
370+
@method requestHeaderFields:with:
371371
@abstract Return a dictionary of header fields that can be used to add the
372372
specified cookies to the request.
373373
@param cookies The cookies to turn into request headers.
374374
@result An NSDictionary where the keys are header field names, and the values
375375
are the corresponding header field values.
376376
*/
377-
public class func requestHeaderFieldsWithCookies(_ cookies: [NSHTTPCookie]) -> [String : String] {
377+
public class func requestHeaderFields(with cookies: [NSHTTPCookie]) -> [String : String] {
378378
var cookieString = cookies.reduce("") { (sum, next) -> String in
379379
return sum + "\(next.cookieRepresentation.name)=\(next.cookieRepresentation.value); "
380380
}
@@ -387,15 +387,15 @@ public class NSHTTPCookie : NSObject {
387387
}
388388

389389
/*!
390-
@method cookiesWithResponseHeaderFields:forURL:
390+
@method cookies:withResponseHeaderFields:forURL:
391391
@abstract Return an array of cookies parsed from the specified response header fields and URL.
392392
@param headerFields The response header fields to check for cookies.
393393
@param URL The URL that the cookies came from - relevant to how the cookies are interpeted.
394394
@result An NSArray of NSHTTPCookie objects
395395
@discussion This method will ignore irrelevant header fields so
396396
you can pass a dictionary containing data other than cookie data.
397397
*/
398-
public class func cookiesWithResponseHeaderFields(_ headerFields: [String : String], forURL URL: NSURL) -> [NSHTTPCookie] { NSUnimplemented() }
398+
public class func cookies(withResponseHeaderFields headerFields: [String : String], forURL URL: NSURL) -> [NSHTTPCookie] { NSUnimplemented() }
399399

400400
/*!
401401
@method properties
@@ -464,7 +464,7 @@ public class NSHTTPCookie : NSObject {
464464
session (regardless of expiration date), NO if receiver need not
465465
be discarded at the end of the session.
466466
*/
467-
public var sessionOnly: Bool {
467+
public var isSessionOnly: Bool {
468468
return self.cookieRepresentation.sessionOnly
469469
}
470470

@@ -504,7 +504,7 @@ public class NSHTTPCookie : NSObject {
504504
@result YES if this cookie should be sent only over secure channels,
505505
NO otherwise.
506506
*/
507-
public var secure: Bool {
507+
public var isSecure: Bool {
508508
return self.cookieRepresentation.secure
509509
}
510510

@@ -520,7 +520,7 @@ public class NSHTTPCookie : NSObject {
520520
@result YES if this cookie should only be sent via HTTP headers,
521521
NO otherwise.
522522
*/
523-
public var HTTPOnly: Bool {
523+
public var isHTTPOnly: Bool {
524524
return self.cookieRepresentation.HTTPOnly
525525
}
526526

TestFoundation/TestNSHTTPCookie.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TestNSHTTPCookie: XCTestCase {
7979
])
8080
XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.comment)
8181
XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.commentURL)
82-
XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.sessionOnly == true)
82+
XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.isSessionOnly == true)
8383

8484
// v0 should never use NSHTTPCookieMaximumAge
8585
XCTAssert(
@@ -88,13 +88,13 @@ class TestNSHTTPCookie: XCTestCase {
8888
)
8989

9090
XCTAssertNil(versionZeroCookieWithInvalidVersionOneProps?.portList)
91-
XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.secure == true)
91+
XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.isSecure == true)
9292
XCTAssert(versionZeroCookieWithInvalidVersionOneProps?.version == 0)
9393
}
9494

9595
func test_RequestHeaderFields() {
9696
let noCookies: [NSHTTPCookie] = []
97-
XCTAssertEqual(NSHTTPCookie.requestHeaderFieldsWithCookies(noCookies)["Cookie"], "")
97+
XCTAssertEqual(NSHTTPCookie.requestHeaderFields(with: noCookies)["Cookie"], "")
9898

9999
let basicCookies: [NSHTTPCookie] = [
100100
NSHTTPCookie(properties: [
@@ -111,7 +111,7 @@ class TestNSHTTPCookie: XCTestCase {
111111
])!,
112112
]
113113

114-
let basicCookieString = NSHTTPCookie.requestHeaderFieldsWithCookies(basicCookies)["Cookie"]
114+
let basicCookieString = NSHTTPCookie.requestHeaderFields(with: basicCookies)["Cookie"]
115115
XCTAssertEqual(basicCookieString, "TestCookie1=testValue1; TestCookie2=testValue2")
116116
}
117-
}
117+
}

0 commit comments

Comments
 (0)