You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTTPURLResponse is part of FoundationNetworking instead of Foundation on non-Darwin platforms.
HTTPURLResponse.init is not accessible in FoundationNetworking, so init(url:statusCode:httpVersion:headerfields:) must be used to test for a missing date header.
HTTPURLResponse.value(forHTTPHeaderField:) is not present in the current release of FoundationNetworking, and allHeaderFields uses keys with different capitalization than the Foundation version. Fixes for both have been implemented in Swift 5.3.
Extraneous whitespace has been removed.
// GMT is required in all timestamps, but section 19.3 of RFC 2616 requires clients to convert timestamps incorrectly given with a different time zone into GMT.
6
10
7
11
// RFC 1123
8
12
"EEE, dd MMM yyyy HH:mm:ss z",
9
-
13
+
10
14
// RFC 850
11
15
"EEEE, dd-MMM-yy HH:mm:ss z",
12
-
16
+
13
17
// ANSI C's asctime() format
14
-
"EEE MMM d HH:mm:ss yyyy"
18
+
"EEE MMM d HH:mm:ss yyyy",
15
19
]
16
20
.lazy // It's very unlikely that any DateFormatter beyond the first will be necessary.
17
21
.map{ formatString ->DateFormatterin
@@ -21,27 +25,33 @@ public extension HTTPURLResponse {
21
25
formatter.dateFormat = formatString
22
26
return formatter
23
27
}
24
-
28
+
25
29
/// The date that the response was sent.
26
30
/// - Note: This is parsed from the `date` header of the response according to [RFC 2616](https://tools.ietf.org/html/rfc2616#section-3.3.1).
27
31
vardate:Date?{
28
32
// Servers are required to send a date header whenever possible. It isn't always possible.
29
33
letdateValue:String?
34
+
35
+
#if canImport(FoundationNetworking) && swift(<5.3) // See https://bugs.swift.org/browse/SR-12300
0 commit comments