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

Aperta
#6,275 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
28/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api, documentation

Direzione di ricerca

Leggi prima la sezione "Raw Response Content" del Quickstart e ispeziona le interfacce esistenti .raw, iter_content() e .content. Chiarisci la semantica di lettura sicura, simile a quella di un file, per i dati della risposta non compressi, incluse quantità di lettura arbitrarie, quindi documenta il comportamento supportato nel Quickstart; il lavoro è completato quando l’API e il suo utilizzo sono specificati chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
54.7k
Fork
10.8k
Merge medio
18m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di psf/requests

Tutte le issue di psf/requests

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.