Skip to content

Commit

Permalink
when an upstream body is unexpectedly closed, return Httpincomplete (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshaw authored Jul 20, 2023
1 parent 8fa004b commit 614d634
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Error types.
use std::error::Error as StdError;
use std::io;
use {crate::wiggle_abi::types::FastlyStatus, url::Url, wiggle::GuestError};

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -154,6 +156,14 @@ impl Error {
Error::HyperError(e) if e.is_parse() => FastlyStatus::Httpinvalid,
Error::HyperError(e) if e.is_user() => FastlyStatus::Httpuser,
Error::HyperError(e) if e.is_incomplete_message() => FastlyStatus::Httpincomplete,
Error::HyperError(e)
if e.source()
.and_then(|e| e.downcast_ref::<io::Error>())
.map(|ioe| ioe.kind())
== Some(io::ErrorKind::UnexpectedEof) =>
{
FastlyStatus::Httpincomplete
}
Error::HyperError(_) => FastlyStatus::Error,
// Destructuring a GuestError is recursive, so we use a helper function:
Error::GuestError(e) => Self::guest_error_fastly_status(e),
Expand Down

0 comments on commit 614d634

Please sign in to comment.