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.

no way to read uncompressed content as file-like object

See original GitHub issue

According to the documentation, there are three ways to read the content of the response: .text, .content and .raw. The first two consider the transfer encoding and decompress the stream automatically when producing their in-memory result. However, especially for the case that the result is large, there is currently no simple way to get at the decompressed result in the form of a file-like object, e.g. to pass it straight into an XML or Json parser.

From the point of view of a library that aims to make HTTP requests user friendly, why should a user have to care about something as low-level as the compression type of the stream that was internally negotiated between the web server and the library? After all, it’s the library’s “fault” if it defaults to accepting such a stream. In this light, the .raw stream is a bit too raw for my taste.

Maybe a fourth property like .stream might provide a better abstraction level?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Reactions:2
  • Comments:44 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
scodercommented, Mar 19, 2013

I already explained why this is a design bug and not a feature request: the existing API uses the wrong abstraction and leaks negotiation details of the connection into user space that are at the mercy of the remote site, and thus, that the user should not have to care about. That renders the current raw stream reading support hard to use. Essentially, this is a request for fixing a feature that’s broken, not a request for a new feature.

1reaction
scodercommented, Jul 26, 2012

Basically, response.raw is a nice-to-have feature that most users would happily ignore and some power-users could find helpful, whereas a compression-independent response.stream is a feature that most streaming users would want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no way to read uncompressed content as file-like object #465
According to the documentation, there are three ways to read the content of the response: .text , .content and .raw . The first...
Read more >
Python: Read compressed (.gz) HDF file without writing and ...
Initialize an SD interface on an HDF file, creating the file if necessary. There is no other way to instantiate an SD object...
Read more >
gzip — Support for gzip files — Python 3.11.1 documentation
The GzipFile class reads and writes gzip-format files, automatically compressing or decompressing the data so that it looks like an ordinary file object....
Read more >
Zip and unzip files and folders on Mac - Apple Support
In the Finder on your Mac, compress files to make a backup copy of your data, ... The unzipped item appears in the...
Read more >
zcommands: Read gzip Compressed Text Files on Linux/Unix
In other words, you need to uncompress the file and then view it temporarily. There must be a better way. Let us explore...
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