Skip to content

Commit 84ea411

Browse files
authored
Add FoundationNetworking hook for reading contents of remote URL (#820)
1 parent c86692f commit 84ea411

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
@@ -2079,6 +2079,14 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
20792079
public static let fileProtectionMask = WritingOptions(rawValue: 0xf0000000)
20802080
}
20812081
#endif
2082+
2083+
#if !FOUNDATION_FRAMEWORK
2084+
@_spi(SwiftCorelibsFoundation)
2085+
public dynamic init(_contentsOfRemote url: URL, options: ReadingOptions = []) throws {
2086+
assert(!url.isFileURL)
2087+
throw CocoaError(.fileReadUnsupportedScheme)
2088+
}
2089+
#endif
20822090

20832091
/// Initialize a `Data` with the contents of a `URL`.
20842092
///
@@ -2098,7 +2106,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
20982106
let d = try NSData(contentsOf: url, options: NSData.ReadingOptions(rawValue: options.rawValue))
20992107
self.init(referencing: d)
21002108
#else
2101-
throw CocoaError(.fileReadUnsupportedScheme)
2109+
try self.init(_contentsOfRemote: url, options: options)
21022110
#endif
21032111
}
21042112
#endif

0 commit comments

Comments
 (0)