Retrying if the HTTP connection drops while reading the body
[?]
Dec 25, 2020, 6:01 PM
VBMXB443FGZL6DLT6KAP2ICFCCQNXCUMDEUL67HB4CNKFMBBNSSACDependencies
- [2]
IQ4FCHPZHTTP connections: pooling + retry on error - [3]
FBXYP7QMForgot to add remote::http - [4]
Q45QHPO4Feedback on network stuff
Change contents
- replacement in pijul/src/remote/http.rs at line 22
) -> Result<(), anyhow::Error> {) -> Result<libpijul::pristine::Hash, anyhow::Error> { - replacement in pijul/src/remote/http.rs at line 31
let mut res = loop {let res = if let Ok(res) = client.get(&url).query(&[("change", &c32)]).send().await {'outer: loop {let mut res = if let Ok(res) = client.get(&url).query(&[("change", &c32)]).send().await {delay = 1f64; - replacement in pijul/src/remote/http.rs at line 42
if res.status().is_success() {break res;} else {if !res.status().is_success() { - replacement in pijul/src/remote/http.rs at line 48
};while let Some(chunk) = res.chunk().await? {debug!("writing {:?}", chunk.len());f.write_all(&chunk)?;loop {match res.chunk().await {Ok(Some(chunk)) => {debug!("writing {:?}", chunk.len());f.write_all(&chunk)?;}Ok(None) => break 'outer,Err(_) => {error!("Error while downloading {:?}, retrying", url);tokio::time::delay_for(std::time::Duration::from_secs_f64(delay)).await;delay *= 2.;break;}}}std::fs::rename(&path_, &path_.with_extension("change"))?; - replacement in pijul/src/remote/http.rs at line 65
std::fs::rename(&path_, &path_.with_extension("change"))?;Ok(())Ok(c) - replacement in pijul/src/remote/http.rs at line 99
t.await??;if send.send(*c).await.is_err() {let c = t.await??;if send.send(c).await.is_err() {