Skip to content

Commit 00cb889

Browse files
committed
address review comments
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent e7c5902 commit 00cb889

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

crates/wasi-http/src/p3/conv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::p3::bindings::http::types::{ErrorCode, Method, Scheme};
22
use core::convert::Infallible;
33

44
impl From<Infallible> for ErrorCode {
5-
fn from(_: Infallible) -> Self {
6-
unreachable!()
5+
fn from(x: Infallible) -> Self {
6+
match x {}
77
}
88
}
99

crates/wasi-http/tests/all/http_server.rs

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub struct Server {
3333

3434
impl Server {
3535
fn new<F>(
36-
run: impl Fn(TokioIo<tokio::net::TcpStream>) -> F + Send + 'static,
3736
conns: usize,
37+
run: impl Fn(TokioIo<tokio::net::TcpStream>) -> F + Send + 'static,
3838
) -> Result<Self>
3939
where
4040
F: Future<Output = Result<()>>,
@@ -74,44 +74,38 @@ impl Server {
7474

7575
pub fn http1(conns: usize) -> Result<Self> {
7676
debug!("initializing http1 server");
77-
Self::new(
78-
|io| async move {
79-
let mut builder = hyper::server::conn::http1::Builder::new();
80-
let http = builder.keep_alive(false).pipeline_flush(true);
77+
Self::new(conns, |io| async move {
78+
let mut builder = hyper::server::conn::http1::Builder::new();
79+
let http = builder.keep_alive(false).pipeline_flush(true);
8180

82-
debug!("preparing to bind connection to service");
83-
let conn = http.serve_connection(io, service_fn(test)).await;
84-
trace!("connection result {:?}", conn);
85-
conn?;
86-
Ok(())
87-
},
88-
conns,
89-
)
81+
debug!("preparing to bind connection to service");
82+
let conn = http.serve_connection(io, service_fn(test)).await;
83+
trace!("connection result {:?}", conn);
84+
conn?;
85+
Ok(())
86+
})
9087
}
9188

9289
pub fn http2(conns: usize) -> Result<Self> {
9390
debug!("initializing http2 server");
94-
Self::new(
95-
|io| async move {
96-
let mut builder = hyper::server::conn::http2::Builder::new(TokioExecutor);
97-
let http = builder.max_concurrent_streams(20);
91+
Self::new(conns, |io| async move {
92+
let mut builder = hyper::server::conn::http2::Builder::new(TokioExecutor);
93+
let http = builder.max_concurrent_streams(20);
9894

99-
debug!("preparing to bind connection to service");
100-
let conn = http.serve_connection(io, service_fn(test)).await;
101-
trace!("connection result {:?}", conn);
102-
if let Err(e) = &conn {
103-
let message = e.to_string();
104-
if message.contains("connection closed before reading preface")
105-
|| message.contains("unspecific protocol error detected")
106-
{
107-
return Ok(());
108-
}
95+
debug!("preparing to bind connection to service");
96+
let conn = http.serve_connection(io, service_fn(test)).await;
97+
trace!("connection result {:?}", conn);
98+
if let Err(e) = &conn {
99+
let message = e.to_string();
100+
if message.contains("connection closed before reading preface")
101+
|| message.contains("unspecific protocol error detected")
102+
{
103+
return Ok(());
109104
}
110-
conn?;
111-
Ok(())
112-
},
113-
conns,
114-
)
105+
}
106+
conn?;
107+
Ok(())
108+
})
115109
}
116110

117111
pub fn addr(&self) -> String {

0 commit comments

Comments
 (0)