Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions crates/wasi-http/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ pub fn hyper_response_error(err: hyper::Error) -> ErrorCode {

ErrorCode::HttpProtocolError
}

impl From<hyper::Error> for ErrorCode {
fn from(err: hyper::Error) -> Self {
hyper_response_error(err)
}
}
7 changes: 4 additions & 3 deletions crates/wasi-http/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! implementation of the wasi-http API.

use crate::{
bindings::http::types::{self, Method, Scheme},
bindings::http::types::{self, ErrorCode, Method, Scheme},
body::{HostIncomingBody, HyperIncomingBody, HyperOutgoingBody},
};
use anyhow::bail;
Expand Down Expand Up @@ -92,11 +92,12 @@ pub trait WasiHttpView {
req: hyper::Request<B>,
) -> wasmtime::Result<Resource<HostIncomingRequest>>
where
B: Body<Data = Bytes, Error = hyper::Error> + Send + 'static,
B: Body<Data = Bytes> + Send + 'static,
B::Error: Into<ErrorCode>,
Self: Sized,
{
let (parts, body) = req.into_parts();
let body = body.map_err(crate::hyper_response_error).boxed_unsync();
let body = body.map_err(Into::into).boxed_unsync();
let body = HostIncomingBody::new(
body,
// TODO: this needs to be plumbed through
Expand Down