aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-proxy/src/proxy_cache.rs
diff options
context:
space:
mode:
authorEdward Wang <[email protected]>2024-10-11 13:44:39 -0700
committerKevin Guthrie <[email protected]>2024-10-28 11:51:38 -0400
commit1db55fc5f6d5fa3e61a5ceb8263e4aee66649fa9 (patch)
tree6c338c7242ae0022450c608dc7f6507de3369731 /pingora-proxy/src/proxy_cache.rs
parent04d7cfeef6205d2cf33ad5704a363ee107250771 (diff)
downloadpingora-1db55fc5f6d5fa3e61a5ceb8263e4aee66649fa9.tar.gz
pingora-1db55fc5f6d5fa3e61a5ceb8263e4aee66649fa9.zip
Apply response_body_filter when serving from cache
Previously the response header filter was applied when serving from cache (using `proxy_cache_hit`), but not the response body filter.
Diffstat (limited to 'pingora-proxy/src/proxy_cache.rs')
-rw-r--r--pingora-proxy/src/proxy_cache.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/pingora-proxy/src/proxy_cache.rs b/pingora-proxy/src/proxy_cache.rs
index 77b7384..e9914cf 100644
--- a/pingora-proxy/src/proxy_cache.rs
+++ b/pingora-proxy/src/proxy_cache.rs
@@ -309,7 +309,23 @@ impl<SV> HttpProxy<SV> {
}
loop {
match session.cache.hit_handler().read_body().await {
- Ok(body) => {
+ Ok(mut body) => {
+ let end = body.is_none();
+ match self
+ .inner
+ .response_body_filter(session, &mut body, end, ctx)
+ {
+ Ok(Some(duration)) => {
+ trace!("delaying response for {duration:?}");
+ time::sleep(duration).await;
+ }
+ Ok(None) => { /* continue */ }
+ Err(e) => {
+ // body is being sent, don't treat downstream as reusable
+ return (false, Some(e));
+ }
+ }
+
if let Some(b) = body {
// write to downstream
if let Err(e) = session