question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to return streaming data from API responses

See original GitHub issue

For potentially large responses which are simply passed directly as a response from my application, I’d like to avoid the overhead of reading in the complete response body, decoding to a string, and parsing the JSON.

I think the best way to expose this would be as an option on Transport.__init__ and extending Connection.perform_request with a stream parameter.

For Urllib3HttpConnection.perform_request this would call urlopen with preload_content=False and returning the response.stream() instead of response.data.

Transport.perform_request could then simply return the iterator instead calling the deserializer.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
honzakralcommented, Jun 17, 2016

Just to update the scan helper (0) now enables ordering so you can use it.

Also implementing this is much easier now, just implement a different connection class (whose perform_request will just return a lazy object) and a serializer (that will wrap the lazy object in another layer providing deserializarion). Everything else will remain working unchanged.

0 - http://elasticsearch-py.readthedocs.io/en/master/helpers.html

0reactions
grjonescommented, Jun 17, 2016

This would be incredibly handy especially as ES continues to move more into the analytics space with large data. A little sad to see this was closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Notes on streaming large API responses
Datasette has the ability to use ASGI trickery to stream all rows from a table (or filtered table) as CSV, potentially returning hundreds...
Read more >
Streaming requests with the fetch API - Chrome Developers
This shows how you can stream data from the user to the server, and send data back that can be processed in real...
Read more >
Why, when and how to return Stream from your Java API ...
Getting more advanced in Java programming, they find stream() method to convert a collection into a stream and learn how to process data...
Read more >
Streaming Data with Spring Boot RESTful Web Service
Spring Boot REST api streaming Options. 1. HttpServletResponse's OutputStream – old approach. This is the oldest approach being used.
Read more >
Streams API - MDN Web Docs - Mozilla
Readable streams​​ Represents a readable stream of data. It can be used to handle response streams of the Fetch API, or developer-defined streams ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found