Closed jonghne closed 3 years ago
curl version is "0.4.34".
Thanks for the report! I think the issue here though is that write_function
can be called multiple times? You only store one value of the closure instead of concatenating everything?
Yeah, your write_function
will be called multiple times with the response buffer in pieces. Try something like this (untested):
transfer.write_function(|data| {
cache += String::from_utf8_lossy(data);
println!("in closure: {}", cache.len());
Ok(data.len())
}).unwrap();
Closing since I believe this question has been answered. If not, feel free to reopen!
my codes as follows:
when I tested post, and checked the result print: the cache length in closure is bigger than outside. the response body length is about 1024bytes. if print the contents in cache, I found I lost the data from the beginning to some random position. Why? waiting for your reply, thank you.