aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSargun Dhillon <[email protected]>2024-10-05 09:47:47 +0000
committerEdward Wang <[email protected]>2024-10-18 13:34:09 -0700
commit63af8e28f24e36db7d4c092a1edbe5dca80d0a23 (patch)
tree983dd0426e7769dd0c16afcbde58f277c20d24c6
parent7419b1967e7686b00aefb7bcd2a4dfe59b31e639 (diff)
downloadpingora-63af8e28f24e36db7d4c092a1edbe5dca80d0a23.tar.gz
pingora-63af8e28f24e36db7d4c092a1edbe5dca80d0a23.zip
Add into_inner() for HTTP client and server
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. Includes-commit: 95aa77098cdfc7667074f2793cd326f496da66a1 Replicated-from: https://github.com/cloudflare/pingora/pull/412
-rw-r--r--.bleep2
-rw-r--r--pingora-core/src/protocols/http/v1/client.rs7
-rw-r--r--pingora-core/src/protocols/http/v1/server.rs7
3 files changed, 15 insertions, 1 deletions
diff --git a/.bleep b/.bleep
index 045b30f..4fc8946 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-ba954539761beee5e5d09b66c3a2957212aa499f
+904af0c56be96e8e51bc6acd04b1c21cdd48138b \ No newline at end of file
diff --git a/pingora-core/src/protocols/http/v1/client.rs b/pingora-core/src/protocols/http/v1/client.rs
index 7125e49..29198b5 100644
--- a/pingora-core/src/protocols/http/v1/client.rs
+++ b/pingora-core/src/protocols/http/v1/client.rs
@@ -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]
diff --git a/pingora-core/src/protocols/http/v1/server.rs b/pingora-core/src/protocols/http/v1/server.rs
index 8dca9d4..9a4bac5 100644
--- a/pingora-core/src/protocols/http/v1/server.rs
+++ b/pingora-core/src/protocols/http/v1/server.rs
@@ -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