Skip to content

Elapsed time to download content is zero. #8054

Answered by Dreamsorcerer
BabakAmini asked this question in Q&A
Discussion options

You must be logged in to vote

As far as I know, session.get() loads headers from the destination server, and then an API like resp.text() downloads the entire content from it.

Not exactly, that's not how HTTP works. It downloads a small amount of data (maybe 4KB or something) and parses the headers from that before returning. When you call any variation of .read() it will then continue from the buffered data and fetch anything more from the server if needed. So, if your responses are small, the network request will have been completed and the connection released before your call to .text().

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Dreamsorcerer
Comment options

@BabakAmini
Comment options

@Dreamsorcerer
Comment options

@BabakAmini
Comment options

@Dreamsorcerer
Comment options

Answer selected by BabakAmini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants