json-stream
json-stream copied to clipboard
Add `httpx` support
Fixes https://github.com/daggaz/json-stream/issues/27
I tried to make each commit reviewable on its own, though the total PR is relatively readable, too.
The duplication between the httpx
and requests
modules (and their tests) feels unfortunate. If you're open to renaming the requests
module something more generic, then we could do something like getattr(response, 'iter_content')
vs getattr(response, 'iter_bytes')
to see which kind of Response
we're dealing with. But I don't feel at all strongly about the topic.
I agree that the duplication between the modules is unfortunate.
In theory you could factor out the "thing that gives you an interable" (specific to requests/httpx) from the "thing that processes an iterable" (maybe change the interface to json_stream.load()
to accept a file or an iterable and wrap appropriately.
But I'm happy to accept this PR as is (pending the resolution of my comments) and I can roll up the refactoring work into some bigger plans I have (related to async support).
🙇 thanks for the review, and for being open to including these tweaks! I think I got everything.