Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read output stream after reading response headers #181

Open
fonsp opened this issue Mar 8, 2022 · 0 comments
Open

Read output stream after reading response headers #181

fonsp opened this issue Mar 8, 2022 · 0 comments

Comments

@fonsp
Copy link
Member

fonsp commented Mar 8, 2022

Some request implementations in other languages work slightly differently: they first return a Response containing HTTP status and headers, after which the user initiates reading.

fetch in JS

image

requests in Python3

image

What this enables is:

  • you can pipe the IO into a JSON/CSV/JPEG/MP3/etc parser, depending on the Content-Type header of the response.
  • you can choose not to read the response body depending on the headers (I'm thinking of cache headers)

I also think this is a "feature" of HTTP: HTTP status and headers are received first, describing how to remaining body should be read.


Is this behaviour already possible with Downloads.request? I have the impression that right now, request will first write the full body content into the given output::IO, and then it returns the Response object containing headers and such.

Thanks for the awesome package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant