json-stream icon indicating copy to clipboard operation
json-stream copied to clipboard

Add `httpx` support

Open vtbassmatt opened this issue 2 years ago • 1 comments

Fixes https://github.com/daggaz/json-stream/issues/27

vtbassmatt avatar Nov 02 '22 17:11 vtbassmatt

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.

vtbassmatt avatar Nov 02 '22 18:11 vtbassmatt

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).

daggaz avatar Nov 03 '22 11:11 daggaz

🙇 thanks for the review, and for being open to including these tweaks! I think I got everything.

vtbassmatt avatar Nov 03 '22 12:11 vtbassmatt