Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/wasi-http/src/p3/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,15 @@ pub async fn default_send_request(
match res {
// `hyper` connection has successfully completed, optimistically poll for response
Ok(()) => send.as_mut().poll(cx),
// `hyper` connection has failed, return the error
Err(err) => Poll::Ready(Err(ErrorCode::from_hyper_request_error(err))),
// `hyper` connection has failed. However, the error may have happened after the
// response was fully received. That can happen when a server sends a body for a
// 204 or 304 response, in violation of the HTTP spec.
// In that case, do what browsers do* and ignore the connection error.
// *: https://github.com/web-platform-tests/wpt/blob/master/fetch/api/basic/response-null-body.any.js
Err(err) => match send.as_mut().poll(cx) {
Poll::Ready(Ok(res)) => Poll::Ready(Ok(res)),
_ => Poll::Ready(Err(ErrorCode::from_hyper_request_error(err))),
},
}
}
})
Expand Down