Retry some pooled connections failing when server closes. Close #10

This is not a perfect solution. It works as long as we are not sending
any body bytes. We discover the error first when attempting to read
the response status line. That means we discover the error after
sending body bytes. To be able to re-send the body, we would need to
introduce a buffer to be able to replay the body on the next
request. We don't currently do that.
This commit is contained in:
Martin Algesten
2019-10-20 21:32:19 +02:00
parent 1264213ca6
commit 753d61b454
5 changed files with 64 additions and 8 deletions

View File

@@ -418,7 +418,10 @@ impl Response {
fn do_from_read(mut reader: impl Read) -> Result<Response, Error> {
//
// HTTP/1.1 200 OK\r\n
let status_line = read_next_line(&mut reader).map_err(|_| Error::BadStatus)?;
let status_line = read_next_line(&mut reader).map_err(|e| match e.kind() {
ErrorKind::ConnectionAborted => Error::BadStatusRead,
_ => Error::BadStatus,
})?;
let (index, status) = parse_status_line(status_line.as_str())?;