From 31d7b63ed7e3a1595903bca3680e130fe90e05a0 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Fri, 7 Jun 2024 15:28:39 -0400 Subject: [PATCH] Add new_h1() back This function turns out to be actually useful for testing and mocking --- .bleep | 2 +- pingora-proxy/src/lib.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.bleep b/.bleep index fbffe75..3128893 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -825cd20ff67b1fb257c704262bfcc35a15c6330d \ No newline at end of file +a73e00f51bc6643e93abedc2a763d38122ffb21d \ No newline at end of file diff --git a/pingora-proxy/src/lib.rs b/pingora-proxy/src/lib.rs index 3b05877..f306387 100644 --- a/pingora-proxy/src/lib.rs +++ b/pingora-proxy/src/lib.rs @@ -312,6 +312,21 @@ impl Session { } } + /// Create a new [Session] from the given [Stream] + /// + /// This function is mostly used for testing and mocking. + pub fn new_h1(stream: Stream) -> Self { + let modules = HttpModules::new(); + Self::new(Box::new(HttpSession::new_http1(stream)), &modules) + } + + /// Create a new [Session] from the given [Stream] with modules + /// + /// This function is mostly used for testing and mocking. + pub fn new_h1_with_modules(stream: Stream, downstream_modules: &HttpModules) -> Self { + Self::new(Box::new(HttpSession::new_http1(stream)), downstream_modules) + } + pub fn as_downstream_mut(&mut self) -> &mut HttpSession { &mut self.downstream_session }