Skip to content

Commit 057297d

Browse files
authored
Add FoundationNetworking hook for reading contents of remote URL (#820) (#826)
1 parent 3e81cb0 commit 057297d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,14 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
20772077
public static let fileProtectionMask = WritingOptions(rawValue: 0xf0000000)
20782078
}
20792079
#endif
2080+
2081+
#if !FOUNDATION_FRAMEWORK
2082+
@_spi(SwiftCorelibsFoundation)
2083+
public dynamic init(_contentsOfRemote url: URL, options: ReadingOptions = []) throws {
2084+
assert(!url.isFileURL)
2085+
throw CocoaError(.fileReadUnsupportedScheme)
2086+
}
2087+
#endif
20802088

20812089
/// Initialize a `Data` with the contents of a `URL`.
20822090
///
@@ -2096,7 +2104,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
20962104
let d = try NSData(contentsOf: url, options: NSData.ReadingOptions(rawValue: options.rawValue))
20972105
self.init(referencing: d)
20982106
#else
2099-
throw CocoaError(.fileReadUnsupportedScheme)
2107+
try self.init(_contentsOfRemote: url, options: options)
21002108
#endif
21012109
}
21022110
#endif

0 commit comments

Comments
 (0)