psf / psf/requests

[Feature request or doc oversight?] Apparently, there's still no way to read uncompressed content as file-like object #465

Open
#6,275 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
54.3k
Forks
10.5k
Avg merge
16h 43m
Merged PRs (30d)
3

Description

This was originally discussed here: https://github.com/psf/requests/issues/465 For some reason the ticket was however closed without a file-like object approach being added here: https://requests.readthedocs.io/en/latest/user/quickstart/ (Other than the somewhat odd .raw that returns something I suspect most people that just want a file-like stream aren't interested in.) There doesn't seem to be an explanation why that ticket was closed, and the discussion suggesting something was fixed but I can't really figure out what.

Since it's not that easy to wrap iter_content() to a file like object with arbitrary read amounts and just wrapping .content for that generically seems to be unsafe to me due to denial of service, it would be nice if this was provided and then documented here: https://requests.readthedocs.io/en/latest/user/quickstart/ (With a section alike to "Raw Response Content".)

The requests version I tested on is: 2.27.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the Quickstart's "Raw Response Content" section and inspect the existing .raw, iter_content(), and .content interfaces first. Clarify the safe file-like reading semantics for uncompressed response data, including arbitrary read amounts, then document the supported behavior in the Quickstart; done means the API and its usage are clearly specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.