From 87f1ed675a8799c4c4eeca2c23ae27c2a8d2e662 Mon Sep 17 00:00:00 2001 From: chesedo Date: Mon, 9 May 2022 11:45:00 +0200 Subject: [PATCH] refactor: improve flow --- src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 241c129..a651d82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -412,6 +412,8 @@ pub async fn call<'a, T: hyper::client::connect::Connect + Clone + Send + Sync + .expect("response does not have an upgrade extension") .await?; + debug!("Responding to a connection upgrade response"); + tokio::spawn(async move { let mut request_upgraded = request_upgraded .expect("request does not have an upgrade extension") @@ -423,13 +425,13 @@ pub async fn call<'a, T: hyper::client::connect::Connect + Clone + Send + Sync + .expect("coping between upgraded connections failed"); }); - return Ok(response); + Ok(response) + } else { + let proxied_response = create_proxied_response(response); + + debug!("Responding to call with response"); + Ok(proxied_response) } - - let proxied_response = create_proxied_response(response); - - debug!("Responding to call with response"); - Ok(proxied_response) } pub struct ReverseProxy {