Skip to content

Commit 4438c6e

Browse files
maksimorlovichjrose-apple
authored andcommitted
Remove two-digit year cookie format support & unit test (fails on Ubuntu 14.04) (#1707)
1 parent e49beda commit 4438c6e

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

Foundation/HTTPCookie.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,8 @@ open class HTTPCookie : NSObject {
104104
return formatter
105105
}()
106106

107-
// Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
108-
static let _formatter2: DateFormatter = {
109-
let formatter = DateFormatter()
110-
formatter.locale = Locale(identifier: "en_US_POSIX")
111-
formatter.dateFormat = "EEEE, dd-MMM-yy HH:mm:ss O"
112-
formatter.timeZone = TimeZone(abbreviation: "GMT")
113-
return formatter
114-
}()
115-
116107
// Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
117-
static let _formatter3: DateFormatter = {
108+
static let _formatter2: DateFormatter = {
118109
let formatter = DateFormatter()
119110
formatter.locale = Locale(identifier: "en_US_POSIX")
120111
formatter.dateFormat = "EEE MMM d HH:mm:ss yyyy"
@@ -123,7 +114,7 @@ open class HTTPCookie : NSObject {
123114
}()
124115

125116
// Sun, 06-Nov-1994 08:49:37 GMT ; Tomcat servers sometimes return cookies in this format
126-
static let _formatter4: DateFormatter = {
117+
static let _formatter3: DateFormatter = {
127118
let formatter = DateFormatter()
128119
formatter.locale = Locale(identifier: "en_US_POSIX")
129120
formatter.dateFormat = "EEE, dd-MMM-yyyy HH:mm:ss O"
@@ -132,7 +123,7 @@ open class HTTPCookie : NSObject {
132123
}()
133124

134125
static let _allFormatters: [DateFormatter]
135-
= [_formatter1, _formatter2, _formatter3, _formatter4]
126+
= [_formatter1, _formatter2, _formatter3]
136127

137128
static let _attributes: [HTTPCookiePropertyKey]
138129
= [.name, .value, .originURL, .version, .domain,

TestFoundation/TestHTTPCookie.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,16 @@ class TestHTTPCookie: XCTestCase {
175175
let cookieString =
176176
"""
177177
format1=true; expires=Wed, 01 Jan 2020 12:30:00 GMT; path=/; domain=swift.org; secure; httponly,
178-
format2=true; expires=Wednesday, 01-Jan-20 12:30:00 GMT; path=/; domain=swift.org; secure; httponly,
179-
format3=true; expires=Wed Jan 1 12:30:00 2020; path=/; domain=swift.org; secure; httponly,
180-
format4=true; expires=Wed, 01-Jan-2020 12:30:00 GMT; path=/; domain=swift.org; secure; httponly
178+
format2=true; expires=Wed Jan 1 12:30:00 2020; path=/; domain=swift.org; secure; httponly,
179+
format3=true; expires=Wed, 01-Jan-2020 12:30:00 GMT; path=/; domain=swift.org; secure; httponly
181180
"""
182181

183182
let header = ["header1":"value1",
184183
"Set-Cookie": cookieString,
185184
"header2":"value2",
186185
"header3":"value3"]
187186
let cookies = HTTPCookie.cookies(withResponseHeaderFields: header, for: URL(string: "https://swift.org")!)
188-
XCTAssertEqual(cookies.count, 4)
187+
XCTAssertEqual(cookies.count, 3)
189188
cookies.forEach { cookie in
190189
XCTAssertEqual(cookie.expiresDate, testDate)
191190
XCTAssertEqual(cookie.domain, "swift.org")

0 commit comments

Comments
 (0)