From: Ian Jackson Date: Sat, 13 Mar 2021 12:23:14 +0000 (+0000) Subject: apitest: handle broken pipe on sse copier X-Git-Tag: otter-0.4.0~131 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9f345cbb3c3f604ea5b08fb24feede7039c1c104;p=otter.git apitest: handle broken pipe on sse copier quel faff! Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index ba07b369..9f07c7cb 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -148,7 +148,19 @@ impl Ctx { let (mut wpipe, rpipe) = UnixStream::pair()?; thread::spawn(move ||{ eprintln!("copy_to'ing"); - sse.copy_to(&mut wpipe).unwrap(); + match sse.copy_to(&mut wpipe) { + Err(re) => match (||{ + // reqwest::Error won't give us the underlying io::Error :-/ + wpipe.write_all(b"\n")?; + wpipe.flush()?; + Ok::<_,io::Error>(()) + })() { + Err(pe) if pe.kind() == ErrorKind::BrokenPipe => { Ok(()) } + Err(pe) => Err(AE::from(pe)), + Ok(_) => Err(AE::from(re)), + } + Ok(_n) => Ok(()), + }.unwrap(); eprintln!("copy_to'd!"); });