Skip to content

Commit

Permalink
Add into_inner() for HTTP client and server
Browse files Browse the repository at this point in the history
This adds the into_inner() function to the stream type, allowing
the HTTP/1.1 client and server to be turned back into a stream.

These functions are useful for implementing HTTP CONNECT or
HTTP Upgrade.
  • Loading branch information
sargun committed Oct 5, 2024
1 parent 8ae4ebb commit 95aa770
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pingora-core/src/protocols/http/v1/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,13 @@ impl HttpSession {
pub fn stream(&self) -> &Stream {
&self.underlying_stream
}

/// Consume `self`, the underlying [Stream] will be returned and can be used
/// directly, for example, in the case of HTTP upgrade. It is not flushed
/// prior to being returned.
pub fn into_inner(self) -> Stream {
self.underlying_stream
}
}

#[inline]
Expand Down
7 changes: 7 additions & 0 deletions pingora-core/src/protocols/http/v1/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,13 @@ impl HttpSession {
pub fn stream(&self) -> &Stream {
&self.underlying_stream
}

/// Consume `self`, the underlying stream will be returned and can be used
/// directly, for example, in the case of HTTP upgrade. The stream is not
/// flushed prior to being returned.
pub fn into_inner(self) -> Stream {
self.underlying_stream
}
}

// Regex to parse request line that has illegal chars in it
Expand Down

0 comments on commit 95aa770

Please sign in to comment.