From fafc38ac59e9539cdfe04f21f4b1e98fa954559e Mon Sep 17 00:00:00 2001 From: Matthew Gumport Date: Mon, 21 Oct 2024 14:55:19 -0700 Subject: change `CachePut::cacheable` to own `ResponseHeader` This changes the `CachePut` trait to take ownership of the response header. We have a use-case for mutating the headers as we process the response, and we would like to avoid copying them in order to do so. --- pingora-proxy/src/proxy_cache.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pingora-proxy/src/proxy_cache.rs') diff --git a/pingora-proxy/src/proxy_cache.rs b/pingora-proxy/src/proxy_cache.rs index 865c592..ed611f8 100644 --- a/pingora-proxy/src/proxy_cache.rs +++ b/pingora-proxy/src/proxy_cache.rs @@ -442,7 +442,7 @@ impl HttpProxy { // the request to fail when the chunked response exceeds the maximum // file size again. if session.cache.max_file_size_bytes().is_some() - && !header.headers.contains_key(header::CONTENT_LENGTH) + && !meta.headers().contains_key(header::CONTENT_LENGTH) { session.cache.disable(NoCacheReason::ResponseTooLarge); return Ok(()); @@ -450,7 +450,7 @@ impl HttpProxy { session.cache.response_became_cacheable(); - if header.status == StatusCode::OK { + if meta.response_header().status == StatusCode::OK { self.inner.cache_miss(session, ctx); } else { // we've allowed caching on the next request, @@ -467,7 +467,7 @@ impl HttpProxy { // on the cache, validate that the response does not exceed the maximum asset size. if session.cache.enabled() { if let Some(max_file_size) = session.cache.max_file_size_bytes() { - let content_length_hdr = header.headers.get(header::CONTENT_LENGTH); + let content_length_hdr = meta.headers().get(header::CONTENT_LENGTH); if let Some(content_length) = header_value_content_length(content_length_hdr) { -- cgit v1.2.3