Allow parsing from an InputStream containing XML #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is kind of a weird backwater of the Apple API, but XMLParser can accept a Stream as input rather than a Data block. This is really nice in the case of FeedKit because it lets the download, the XML parsing, and the feed parsing all run concurrently. The time savings can be quite noticeable for large feeds. No other way of initializing an XMLParser gives this effect.
This patch adds a
FeedParser(xmlStream:)
initializer that propagates down toXMLFeedParser(xmlStream:)
, bypassing format-type detection.Unfortunately, this isn't a complete solution on its own because you still need some way of getting a network data stream into the form of an InputStream, which as far as I can tell isn't a feature that's implemented in the Foundation API. I have some code that converts a URLSessionDataTask into a stream and I'd be happy to share it if you're interested, but it seems a bit peripheral to the core features of FeedKit.