Skip to content

Commit abf3278

Browse files
authored
Merge pull request #2401 from millenomi/urlcache-adoption
Parity: URLCache adoption for HTTP and FTP invocations.
2 parents fff32f5 + 86caf0b commit abf3278

16 files changed

+1222
-106
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ if(ENABLE_TESTING)
511511
TestFoundation/TestTimeZone.swift
512512
TestFoundation/TestUnitConverter.swift
513513
TestFoundation/TestUnit.swift
514+
TestFoundation/TestURLCache.swift
514515
TestFoundation/TestURLCredential.swift
515516
TestFoundation/TestURLProtectionSpace.swift
516517
TestFoundation/TestURLProtocol.swift

Foundation.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1513A8432044893F00539722 /* FileManager_XDG.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1513A8422044893F00539722 /* FileManager_XDG.swift */; };
1313
1520469B1D8AEABE00D02E36 /* HTTPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1520469A1D8AEABE00D02E36 /* HTTPServer.swift */; };
1414
1539391422A07007006DFF4F /* TestCachedURLResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1539391322A07007006DFF4F /* TestCachedURLResponse.swift */; };
15+
1539391522A07160006DFF4F /* TestNSSortDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 152EF3932283457B001E1269 /* TestNSSortDescriptor.swift */; };
1516
153CC8352215E00200BFE8F3 /* ScannerAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 153CC8322214C3D100BFE8F3 /* ScannerAPI.swift */; };
1617
153E951120111DC500F250BE /* CFKnownLocations.h in Headers */ = {isa = PBXBuildFile; fileRef = 153E950F20111DC500F250BE /* CFKnownLocations.h */; settings = {ATTRIBUTES = (Private, ); }; };
1718
153E951220111DC500F250BE /* CFKnownLocations.c in Sources */ = {isa = PBXBuildFile; fileRef = 153E951020111DC500F250BE /* CFKnownLocations.c */; };
@@ -31,6 +32,7 @@
3132
1578DA11212B407B003C9516 /* CFString_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1578DA10212B407B003C9516 /* CFString_Internal.h */; };
3233
1578DA13212B4C35003C9516 /* CFOverflow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1578DA12212B4C35003C9516 /* CFOverflow.h */; };
3334
1578DA15212B6F33003C9516 /* CFCollections_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1578DA14212B6F33003C9516 /* CFCollections_Internal.h */; };
35+
1581706322B1A29100348861 /* TestURLCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1581706222B1A29100348861 /* TestURLCache.swift */; };
3436
158BCCAA2220A12600750239 /* TestDateIntervalFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 158BCCA92220A12600750239 /* TestDateIntervalFormatter.swift */; };
3537
158BCCAD2220A18F00750239 /* CFDateIntervalFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 158BCCAB2220A18F00750239 /* CFDateIntervalFormatter.h */; settings = {ATTRIBUTES = (Private, ); }; };
3638
158BCCAE2220A18F00750239 /* CFDateIntervalFormatter.c in Sources */ = {isa = PBXBuildFile; fileRef = 158BCCAC2220A18F00750239 /* CFDateIntervalFormatter.c */; };
@@ -651,6 +653,7 @@
651653
1578DA10212B407B003C9516 /* CFString_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFString_Internal.h; sourceTree = "<group>"; };
652654
1578DA12212B4C35003C9516 /* CFOverflow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFOverflow.h; sourceTree = "<group>"; };
653655
1578DA14212B6F33003C9516 /* CFCollections_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFCollections_Internal.h; sourceTree = "<group>"; };
656+
1581706222B1A29100348861 /* TestURLCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestURLCache.swift; sourceTree = "<group>"; };
654657
158BCCA92220A12600750239 /* TestDateIntervalFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDateIntervalFormatter.swift; sourceTree = "<group>"; };
655658
158BCCAB2220A18F00750239 /* CFDateIntervalFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFDateIntervalFormatter.h; sourceTree = "<group>"; };
656659
158BCCAC2220A18F00750239 /* CFDateIntervalFormatter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFDateIntervalFormatter.c; sourceTree = "<group>"; };
@@ -1771,6 +1774,7 @@
17711774
84BA558D1C16F90900F48C54 /* TestTimeZone.swift */,
17721775
EA66F6431BF1619600136161 /* TestURL.swift */,
17731776
F9E0BB361CA70B8000F7FF3C /* TestURLCredential.swift */,
1777+
1581706222B1A29100348861 /* TestURLCache.swift */,
17741778
83712C8D1C1684900049AD49 /* TestNSURLRequest.swift */,
17751779
DAA79BD820D42C07004AF044 /* TestURLProtectionSpace.swift */,
17761780
7A7D6FBA1C16439400957E2E /* TestURLResponse.swift */,
@@ -2916,8 +2920,10 @@
29162920
5B13B3271C582D4C00651CE2 /* TestNSArray.swift in Sources */,
29172921
5B13B3461C582D4C00651CE2 /* TestProcess.swift in Sources */,
29182922
555683BD1C1250E70041D4C6 /* TestUserDefaults.swift in Sources */,
2923+
1539391522A07160006DFF4F /* TestNSSortDescriptor.swift in Sources */,
29192924
DCA8120B1F046D13000D0C86 /* TestCodable.swift in Sources */,
29202925
7900433B1CACD33E00ECCBF1 /* TestNSCompoundPredicate.swift in Sources */,
2926+
1581706322B1A29100348861 /* TestURLCache.swift in Sources */,
29212927
);
29222928
runOnlyForDeploymentPostprocessing = 0;
29232929
};

Foundation/NSKeyedArchiver.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ open class NSKeyedArchiver : NSCoder {
9494
/// The archiver’s delegate.
9595
open weak var delegate: NSKeyedArchiverDelegate?
9696

97+
/// The latest error.
98+
private var _error: Error?
99+
open override var error: Error? {
100+
get { return _error }
101+
set { _error = newValue }
102+
}
103+
97104
/// The format in which the receiver encodes its data.
98105
///
99106
/// The available formats are `xml` and `binary`.

Foundation/NSKeyedUnarchiver.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ open class NSKeyedUnarchiver : NSCoder {
7979
unarchiver.requiresSecureCoding = true
8080
unarchiver.decodingFailurePolicy = .setErrorAndReturn
8181

82-
return try unarchiver.decodeObject(of: classes, forKey: NSKeyedArchiveRootObjectKey)
82+
let result = unarchiver.decodeObject(of: classes, forKey: NSKeyedArchiveRootObjectKey)
83+
if let error = unarchiver.error {
84+
throw error
85+
}
86+
return result
8387
}
8488

8589
@available(swift, deprecated: 9999, renamed: "unarchivedObject(ofClass:from:)")

Foundation/NSURLRequest.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ open class NSMutableURLRequest : NSURLRequest {
564564
get { return super.httpShouldUsePipelining }
565565
set { super.httpShouldUsePipelining = newValue }
566566
}
567+
568+
// These properties are settable using URLProtocol's class methods.
569+
var protocolProperties: [String: Any] = [:]
567570
}
568571

569572
/// Returns an existing key-value pair inside the header fields if it exists.

0 commit comments

Comments
 (0)