Skip to content

Commit 26ac0e7

Browse files
authored
Merge pull request #858 from ianpartridge/httpcookie
2 parents 2c75086 + fe2916c commit 26ac0e7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Foundation/NSHTTPCookie.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ open class HTTPCookie : NSObject {
380380
/// - Parameter headerFields: The response header fields to check for cookies.
381381
/// - Parameter URL: The URL that the cookies came from - relevant to how the cookies are interpeted.
382382
/// - Returns: An array of NSHTTPCookie objects
383-
open class func cookies(withResponseHeaderFields headerFields: [String : String], forURL url: URL) -> [HTTPCookie] {
383+
open class func cookies(withResponseHeaderFields headerFields: [String : String], for URL: URL) -> [HTTPCookie] {
384384

385385
//HTTP Cookie parsing based on RFC 6265: https://tools.ietf.org/html/rfc6265
386386
//Though RFC6265 suggests that multiple cookies cannot be folded into a single Set-Cookie field, this is
@@ -405,7 +405,7 @@ open class HTTPCookie : NSObject {
405405
//bake the cookies
406406
var httpCookies: [HTTPCookie] = []
407407
for i in 0..<cookieIndices.count-1 {
408-
if let aCookie = createHttpCookie(url: url, pairs: nameValuePairs[cookieIndices[i]..<cookieIndices[i+1]]) {
408+
if let aCookie = createHttpCookie(url: URL, pairs: nameValuePairs[cookieIndices[i]..<cookieIndices[i+1]]) {
409409
httpCookies.append(aCookie)
410410
}
411411
}

TestFoundation/TestNSHTTPCookie.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ class TestNSHTTPCookie: XCTestCase {
125125
"Set-Cookie": "fr=anjd&232; Max-Age=7776000; path=/; domain=.example.com; secure; httponly",
126126
"header2":"value2",
127127
"header3":"value3"]
128-
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, forURL: URL(string: "http://example.com")!)
128+
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "http://example.com")!)
129129
XCTAssertEqual(cookies.count, 1)
130130
XCTAssertEqual(cookies[0].name, "fr")
131131
XCTAssertEqual(cookies[0].value, "anjd&232")
132132
}
133133

134134
func test_cookiesWithResponseHeader0cookies() {
135135
let header = ["header1":"value1", "header2":"value2", "header3":"value3"]
136-
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, forURL: URL(string: "http://example.com")!)
136+
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "http://example.com")!)
137137
XCTAssertEqual(cookies.count, 0)
138138
}
139139

@@ -142,7 +142,7 @@ class TestNSHTTPCookie: XCTestCase {
142142
"Set-Cookie": "fr=a&2@#; Max-Age=1186000; path=/; domain=.example.com; secure, xd=plm!@#;path=/;domain=.example2.com",
143143
"header2":"value2",
144144
"header3":"value3"]
145-
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, forURL: URL(string: "http://example.com")!)
145+
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "http://example.com")!)
146146
XCTAssertEqual(cookies.count, 2)
147147
XCTAssertTrue(cookies[0].isSecure)
148148
XCTAssertFalse(cookies[1].isSecure)
@@ -153,7 +153,7 @@ class TestNSHTTPCookie: XCTestCase {
153153
"Set-Cookie": "fr=anjd&232; expires=Wed, 21 Sep 2016 05:33:00 GMT; Max-Age=7776000; path=/; secure; httponly",
154154
"header2":"value2",
155155
"header3":"value3"]
156-
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, forURL: URL(string: "http://example.com")!)
156+
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "http://example.com")!)
157157
XCTAssertEqual(cookies[0].domain, "http://example.com")
158158
XCTAssertNotNil(cookies[0].expiresDate)
159159

@@ -173,7 +173,7 @@ class TestNSHTTPCookie: XCTestCase {
173173
"Set-Cookie": "fr=tx; expires=Wed, 21-Sep-2016 05:33:00 GMT; Max-Age=7776000; secure; httponly",
174174
"header2":"value2",
175175
"header3":"value3"]
176-
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, forURL: URL(string: "http://example.com")!)
176+
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "http://example.com")!)
177177
XCTAssertEqual(cookies[0].domain, "http://example.com")
178178
XCTAssertEqual(cookies[0].path, "/")
179179
}

0 commit comments

Comments
 (0)