aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-proxy/src/proxy_trait.rs
diff options
context:
space:
mode:
authorMatthew Gumport <[email protected]>2024-12-13 15:07:12 -0800
committerYuchen Wu <[email protected]>2024-12-20 13:39:24 -0800
commita37224b50061d3a2e76ef1fbd87d426c7b904d51 (patch)
tree5130d44671578701f3d1c66f95804aface7e236d /pingora-proxy/src/proxy_trait.rs
parent2a94183feba3bee207c812fc543481ff98635db2 (diff)
downloadpingora-a37224b50061d3a2e76ef1fbd87d426c7b904d51.tar.gz
pingora-a37224b50061d3a2e76ef1fbd87d426c7b904d51.zip
add range_header_filter to proxy traitHEADmain
This makes the `range_header_filter` overridable. The new default implementation is what we were doing instead of calling a hook.
Diffstat (limited to 'pingora-proxy/src/proxy_trait.rs')
-rw-r--r--pingora-proxy/src/proxy_trait.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/pingora-proxy/src/proxy_trait.rs b/pingora-proxy/src/proxy_trait.rs
index 00e54f4..e67a9f0 100644
--- a/pingora-proxy/src/proxy_trait.rs
+++ b/pingora-proxy/src/proxy_trait.rs
@@ -18,6 +18,7 @@ use pingora_cache::{
CacheKey, CacheMeta, ForcedInvalidationKind,
RespCacheable::{self, *},
};
+use proxy_cache::range_filter::{self};
use std::time::Duration;
/// The interface to control the HTTP proxy
@@ -216,6 +217,23 @@ pub trait ProxyHttp {
)
}
+ /// This filter is called when cache is enabled to determine what byte range to return (in both
+ /// cache hit and miss cases) from the response body. It is only used when caching is enabled,
+ /// otherwise the upstream is responsible for any filtering. It allows users to define the range
+ /// this request is for via its return type `range_filter::RangeType`.
+ ///
+ /// It also allow users to modify the response header accordingly.
+ ///
+ /// The default implementation can handle a single-range as per [RFC7232].
+ fn range_header_filter(
+ &self,
+ req: &RequestHeader,
+ resp: &mut ResponseHeader,
+ _ctx: &mut Self::CTX,
+ ) -> range_filter::RangeType {
+ proxy_cache::range_filter::range_header_filter(req, resp)
+ }
+
/// Modify the request before it is sent to the upstream
///
/// Unlike [Self::request_filter()], this filter allows to change the request headers to send