Replies: 6 comments
-
Well, no, Response is a struct: pub struct Response {
pub mut:
text string
header Header
status_code int
status_msg string
http_version string
} It currently reads the entire body into the |
Beta Was this translation helpful? Give feedback.
-
I found the source code of HTTP in here. Lines 150 to 168 in 82e6d6e When the request is over, read the text returned by the request from here, and then generate a Response This step should be reserved for the user, otherwise, all the data will be loaded into the memory, and functions like the download progress bar cannot be done with this |
Beta Was this translation helpful? Give feedback.
-
I'd rather have both. If you're doing something where you know the response data won't be "big" (which is relative, I know), there's no need of the overhead of extra processing to stream it, just let the routine hand it back. However, sometimes it is good to be able to stream the data, especially if it is really "big", or you only want to save a few bits out of the middle - instead of loading the whole thing first, copying pieces out, then throwing away what was downloaded. |
Beta Was this translation helpful? Give feedback.
-
It V got a Maybe I can make a PR |
Beta Was this translation helpful? Give feedback.
-
Has this been taken into development yet? I would really like to see this feature in V. |
Beta Was this translation helpful? Give feedback.
-
Would be great to have this! And a good base for more advanced features. import net.http
import time
fn main() {
start := time.ticks()
// resp := http.get('https://speed.hetzner.de/100MB.bin')!
http.download_file('https://speed.hetzner.de/100MB.bin', '100MB.bin')!
println('Took: ${f64(time.ticks() - start) / 1000:.2f}s')
}
In go the response body is a reader which makes it a breeze to read a chunk at a time. |
Beta Was this translation helpful? Give feedback.
-
Response in
net.http
is not a readerso, many stream-based functions cannot work.
Beta Was this translation helpful? Give feedback.
All reactions