Callback for download requests
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
So I want to download a very big file, but with the current API I can only store it in memory and then write to a file, that is a HUGE problem, also I want to show a progress bar or something like that, so I figure out a manner to make this possible:
```rust
struct Manager;
impl Manager {
pub fn new() -> Manager {
Manager {}
}
}
impl surf::DownloadManager for Manager {
async fn process_headers(&self, headers: HEADERS) {
// Process content-length, content-disposition, etc
}
async fn process_chunk(&self, chunk: &[u8]) {
// Write chunk to disk and report download progress...
}
}
async fn get() -> Result<(), surf::Exception> {
let mngr = Manager::new();
let mut res = surf::callback_request::get("https://httpbin.org/get", mngr).await?;
Ok(())
}
```
What do you think?
for now, I am using curl directly
Contributor guide
Assessment
This issue has not been assessed yet.