From 3cdc6fcf83d5b5644ef390d8ab1f1e81d251cfab Mon Sep 17 00:00:00 2001 From: Harshil Sanjay Jain Date: Wed, 22 May 2024 09:47:36 -0400 Subject: [PATCH] Add include-http-headers field to cache key policy --- .../BackendServiceCdnCacheKeyPolicy.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/gyro/google/compute/BackendServiceCdnCacheKeyPolicy.java b/src/main/java/gyro/google/compute/BackendServiceCdnCacheKeyPolicy.java index 2eeb295a..f04eeb3f 100644 --- a/src/main/java/gyro/google/compute/BackendServiceCdnCacheKeyPolicy.java +++ b/src/main/java/gyro/google/compute/BackendServiceCdnCacheKeyPolicy.java @@ -33,6 +33,7 @@ public class BackendServiceCdnCacheKeyPolicy extends Diffable implements Copyabl private Boolean includeQueryString; private List queryStringBlacklist; private List queryStringWhitelist; + private List includeHttpHeaders; /** * If true, requests to different hosts will be cached separately. @@ -102,6 +103,22 @@ public void setQueryStringWhitelist(List queryStringWhitelist) { this.queryStringWhitelist = queryStringWhitelist; } + /** + * The HTTP request headers (by name) to be used in the cache key. + */ + @Updatable + public List getIncludeHttpHeaders() { + if (includeHttpHeaders == null) { + includeHttpHeaders = new ArrayList<>(); + } + + return includeHttpHeaders; + } + + public void setIncludeHttpHeaders(List includeHttpHeaders) { + this.includeHttpHeaders = includeHttpHeaders; + } + @Override public String primaryKey() { return ""; @@ -123,6 +140,7 @@ public void copyFrom(CacheKeyPolicy model) { setQueryStringBlacklist(model.getQueryStringBlacklistList()); setQueryStringWhitelist(model.getQueryStringWhitelistList()); + setIncludeHttpHeaders(model.getIncludeHttpHeadersList()); } CacheKeyPolicy toCacheKeyPolicy() { @@ -132,6 +150,7 @@ CacheKeyPolicy toCacheKeyPolicy() { .setIncludeQueryString(TRUE.equals(getIncludeQueryString())) .addAllQueryStringBlacklist(getQueryStringBlacklist()) .addAllQueryStringWhitelist(getQueryStringWhitelist()) + .addAllIncludeHttpHeaders(getIncludeHttpHeaders()) .build(); } }