diff --git a/source/extensions/filters/http/cache/cache_filter_utils.cc b/source/extensions/filters/http/cache/cache_filter_utils.cc index 12fcf647be4e..30041abe69bf 100644 --- a/source/extensions/filters/http/cache/cache_filter_utils.cc +++ b/source/extensions/filters/http/cache/cache_filter_utils.cc @@ -12,7 +12,7 @@ bool CacheFilterUtils::isCacheableRequest(const Http::RequestHeaderMap& headers) const Http::HeaderValues& header_values = Http::Headers::get(); // TODO(toddmgreer): Also serve HEAD requests from cache. // TODO(toddmgreer): Check all the other cache-related headers. - return method && forwarded_proto && headers.Path() && headers.Host() && + return method && forwarded_proto && !headers.Authorization() && headers.Path() && headers.Host() && (method->value() == header_values.MethodValues.Get) && (forwarded_proto->value() == header_values.SchemeValues.Http || forwarded_proto->value() == header_values.SchemeValues.Https); diff --git a/test/extensions/filters/http/cache/cache_filter_utils_test.cc b/test/extensions/filters/http/cache/cache_filter_utils_test.cc index 4f90b47905b9..b43399b25602 100644 --- a/test/extensions/filters/http/cache/cache_filter_utils_test.cc +++ b/test/extensions/filters/http/cache/cache_filter_utils_test.cc @@ -33,23 +33,27 @@ IsCacheableRequestParams params[] = { false }, { - {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "https"}, {":authority", "test"}}, + {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "https"}, {":authority", "test.com"}}, true }, { - {{":path", "/"}, {":method", "POST"}, {"x-forwarded-proto", "https"}, {":authority", "test"}}, + {{":path", "/"}, {":method", "POST"}, {"x-forwarded-proto", "https"}, {":authority", "test.com"}}, false }, { - {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test"}}, + {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}}, true }, { - {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test"}}, + {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}}, true }, { - {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "ftp"}, {":authority", "test"}}, + {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "ftp"}, {":authority", "test.com"}}, + false + }, + { + {{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}, {"authorization", "basic YWxhZGRpbjpvcGVuc2VzYW1l"}}, false }, };