Add new_h1() back

This function turns out to be actually useful for testing and mocking
This commit is contained in:
Yuchen Wu 2024-06-07 15:28:39 -04:00 committed by Kevin Guthrie
parent 8a8302cf7b
commit 31d7b63ed7
2 changed files with 16 additions and 1 deletions

2
.bleep
View file

@ -1 +1 @@
825cd20ff67b1fb257c704262bfcc35a15c6330d
a73e00f51bc6643e93abedc2a763d38122ffb21d

View file

@ -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
}