@@ -6,15 +6,15 @@ use anyhow::anyhow;
66use async_trait:: async_trait;
77use futures:: { Stream , StreamExt } ;
88use http_body_util:: combinators:: BoxBody ;
9- use hyper :: { Method , Request , Response , StatusCode } ;
9+ use http_body_util :: Full ;
1010use hyper:: body:: { Body , Bytes , Incoming } ;
11- use hyper:: http :: uri :: PathAndQuery ;
11+ use hyper:: client :: conn :: http1 as http1_client ;
1212use hyper:: header:: HeaderValue ;
13+ use hyper:: http:: uri:: PathAndQuery ;
1314use hyper:: server:: conn:: http1 as http1_server;
14- use hyper:: client:: conn:: http1 as http1_client;
1515use hyper:: service:: service_fn;
16+ use hyper:: { Method , Request , Response , StatusCode } ;
1617use hyper_util:: rt:: TokioIo ;
17- use http_body_util:: Full ;
1818use log:: { debug, error} ;
1919use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
2020use tokio:: io:: { AsyncRead , AsyncReadExt , AsyncWrite , AsyncWriteExt } ;
@@ -211,7 +211,8 @@ async fn proxy(
211211
212212fn with_boxed_body < B > ( resp : Response < B > ) -> Response < BoxBody < Bytes , anyhow:: Error > >
213213where
214- B : Body < Data = Bytes > + Send + Sync + ' static , <B as hyper:: body:: Body >:: Error : std:: error:: Error + Send + Sync
214+ B : Body < Data = Bytes > + Send + Sync + ' static ,
215+ <B as hyper:: body:: Body >:: Error : std:: error:: Error + Send + Sync ,
215216{
216217 use http_body_util:: BodyExt ;
217218
@@ -246,9 +247,7 @@ async fn handle_connect(
246247 // Connect to remote server before the upgrade so we can return an error if it fails
247248 let mut remote = match remote_connect ( egress_port, authority. host ( ) , port) . await {
248249 Ok ( remote) => remote,
249- Err ( err) => {
250- return err_resp ( StatusCode :: SERVICE_UNAVAILABLE , err. to_string ( ) )
251- }
250+ Err ( err) => return err_resp ( StatusCode :: SERVICE_UNAVAILABLE , err. to_string ( ) ) ,
252251 } ;
253252
254253 tokio:: task:: spawn ( async move {
@@ -280,7 +279,11 @@ async fn handle_request(
280279) -> anyhow:: Result < Response < BoxBody < Bytes , anyhow:: Error > > > {
281280 let host = match req. uri ( ) . host ( ) {
282281 Some ( host) => host,
283- None => return Ok ( with_boxed_body ( bad_request ( "URI is missing a host" . to_string ( ) ) ) ) ,
282+ None => {
283+ return Ok ( with_boxed_body ( bad_request (
284+ "URI is missing a host" . to_string ( ) ,
285+ ) ) )
286+ }
284287 } ;
285288 let port = req. uri ( ) . port_u16 ( ) . unwrap_or ( 80 ) ;
286289
@@ -390,12 +393,12 @@ async fn remote_connect(egress_port: u32, host: &str, port: u16) -> anyhow::Resu
390393mod tests {
391394 use assert2:: assert;
392395 use http:: { uri:: PathAndQuery , Method , Version } ;
393- use hyper :: { Request , Response } ;
396+ use http_body_util :: { BodyExt , Full } ;
394397 use hyper:: body:: { Bytes , Incoming } ;
395398 use hyper:: server:: conn:: http1 as http1_server;
396399 use hyper:: service:: service_fn;
400+ use hyper:: { Request , Response } ;
397401 use hyper_util:: rt:: TokioIo ;
398- use http_body_util:: { Full , BodyExt } ;
399402 use rand:: RngCore ;
400403 use std:: convert:: Infallible ;
401404 use std:: net:: { Ipv4Addr , SocketAddr } ;
0 commit comments