diff --git a/CHANGELOG.md b/CHANGELOG.md index c62972f..a49943e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. -## [2.5.2] - 2024-06-13 -### Changed -- (On Device Decisioning) When proxy is configured send empty Authorization header on artifact rules request to bypass proxy-level cache +## [2.6.0] - 2024-06-13 +### Added +- (On Device Decisioning) Added new configuration option (`shouldArtifactRequestBypassProxyCache`). When enabled and a proxy is configured, send empty Authorization header on artifact rules request to bypass proxy-level cache + ## [2.5.1] - 2024-01-12 ### Fixed - Fix geo context not being cleaned up diff --git a/src/main/java/com/adobe/target/edge/client/ClientConfig.java b/src/main/java/com/adobe/target/edge/client/ClientConfig.java index 847a5c3..7c70b72 100644 --- a/src/main/java/com/adobe/target/edge/client/ClientConfig.java +++ b/src/main/java/com/adobe/target/edge/client/ClientConfig.java @@ -52,6 +52,7 @@ public class ClientConfig { private boolean telemetryEnabled; private List onDeviceAllMatchingRulesMboxes; private HttpClient httpClient; + private boolean shouldArtifactRequestBypassProxyCache; public String getClient() { return client; @@ -172,6 +173,10 @@ public boolean isTelemetryEnabled() { return telemetryEnabled; } + public boolean shouldArtifactRequestBypassProxyCache() { + return shouldArtifactRequestBypassProxyCache; + } + public static final class ClientConfigBuilder { private static final String CLUSTER_PREFIX = "mboxedge"; private static final String DELIVERY_PATH_SUFFIX = "/rest/v1/delivery"; @@ -202,11 +207,13 @@ public static final class ClientConfigBuilder { private boolean telemetryEnabled = true; private List onDeviceAllMatchingRulesMboxes; private HttpClient httpClient; + private boolean shouldArtifactRequestBypassProxyCache = false; private ClientConfigBuilder() {} /** * Client Code + * * @param client * @return ClientConfigBuilder */ @@ -217,6 +224,7 @@ public ClientConfigBuilder client(String client) { /** * Organization ID + * * @param organizationId * @return ClientConfigBuilder */ @@ -227,6 +235,7 @@ public ClientConfigBuilder organizationId(String organizationId) { /** * Server Domain + * * @param serverDomain * @return ClientConfigBuilder */ @@ -237,6 +246,7 @@ public ClientConfigBuilder serverDomain(String serverDomain) { /** * Default Property Token + * * @param defaultPropertyToken * @return ClientConfigBuilder */ @@ -246,8 +256,8 @@ public ClientConfigBuilder defaultPropertyToken(String defaultPropertyToken) { } /** - * Secure (HTTPS) or not - * Default value is true + * Secure (HTTPS) or not Default value is true + * * @param secure * @return ClientConfigBuilder */ @@ -257,8 +267,8 @@ public ClientConfigBuilder secure(boolean secure) { } /** - * Socket Timeout - * Default value is 10000 + * Socket Timeout Default value is 10000 + * * @param socketTimeout * @return ClientConfigBuilder */ @@ -268,8 +278,8 @@ public ClientConfigBuilder socketTimeout(int socketTimeout) { } /** - * Connect Timeout - * Default value is 10000 + * Connect Timeout Default value is 10000 + * * @param connectTimeout * @return ClientConfigBuilder */ @@ -279,8 +289,8 @@ public ClientConfigBuilder connectTimeout(int connectTimeout) { } /** - * Max Connections Per Host - * Default value is 100 + * Max Connections Per Host Default value is 100 + * * @param maxConnectionsPerHost * @return ClientConfigBuilder */ @@ -290,8 +300,8 @@ public ClientConfigBuilder maxConnectionsPerHost(int maxConnectionsPerHost) { } /** - * Max Connections Total - * Default value is 200 + * Max Connections Total Default value is 200 + * * @param maxConnectionsTotal * @return ClientConfigBuilder */ @@ -301,9 +311,10 @@ public ClientConfigBuilder maxConnectionsTotal(int maxConnectionsTotal) { } /** - * Total time to live (TTL) defines maximum life span of persistent connections regardless of their - * expiration setting. No persistent connection will be re-used past its TTL value. + * Total time to live (TTL) defines maximum life span of persistent connections regardless of + * their expiration setting. No persistent connection will be re-used past its TTL value. * Default value is -1 which means that connections will be kept alive indefinitely. + * * @param connectionTtlMs * @return ClientConfigBuilder */ @@ -313,11 +324,11 @@ public ClientConfigBuilder connectionTtlMs(int connectionTtlMs) { } /** - * Idle connection validation interval defines period of inactivity in milliseconds after which persistent - * connections must be re-validated prior to being leased to the consumer. Non-positive value effectively - * disables idle connection validation. - * Note: Only available for the Apache sync client - * Default value is 1000 + * Idle connection validation interval defines period of inactivity in milliseconds after which + * persistent connections must be re-validated prior to being leased to the consumer. + * Non-positive value effectively disables idle connection validation. Note: Only available for + * the Apache sync client Default value is 1000 + * * @param idleConnectionValidationMs * @return ClientConfigBuilder */ @@ -327,8 +338,9 @@ public ClientConfigBuilder idleConnectionValidationMs(int idleConnectionValidati } /** - * The time in seconds to evict idle connections from the connection pool. - * Default value is 20 + * The time in seconds to evict idle connections from the connection pool. Default value is + * 20 + * * @param evictIdleConnectionsAfterSecs * @return ClientConfigBuilder */ @@ -338,8 +350,8 @@ public ClientConfigBuilder evictIdleConnectionsAfterSecs(int evictIdleConnection } /** - * Enable retries - * Default value is true + * Enable retries Default value is true + * * @param enableRetries * @return ClientConfigBuilder */ @@ -349,8 +361,8 @@ public ClientConfigBuilder enableRetries(boolean enableRetries) { } /** - * Log requests - * Default value is false + * Log requests Default value is false + * * @param logRequests * @return ClientConfigBuilder */ @@ -360,8 +372,8 @@ public ClientConfigBuilder logRequests(boolean logRequests) { } /** - * Telemetry Enabled - * Default value is true + * Telemetry Enabled Default value is true + * * @param telemetryEnabled * @return ClientConfigBuilder */ @@ -371,8 +383,8 @@ public ClientConfigBuilder telemetryEnabled(boolean telemetryEnabled) { } /** - * Log request status - * Default value is false + * Log request status Default value is false + * * @param logRequestStatus * @return ClientConfigBuilder */ @@ -383,6 +395,7 @@ public ClientConfigBuilder logRequestStatus(boolean logRequestStatus) { /** * Request Interceptor + * * @param requestInterceptor * @return ClientConfigBuilder */ @@ -393,6 +406,7 @@ public ClientConfigBuilder requestInterceptor(HttpRequestInterceptor requestInte /** * Proxy Configuration + * * @param proxyConfig * @return ClientConfigBuilder */ @@ -403,6 +417,7 @@ public ClientConfigBuilder proxyConfig(ClientProxyConfig proxyConfig) { /** * Exception Handler + * * @param handler * @return ClientConfigBuilder */ @@ -413,6 +428,7 @@ public ClientConfigBuilder exceptionHandler(TargetExceptionHandler handler) { /** * On Device Decisioning Handler + * * @param handler * @return ClientConfigBuilder */ @@ -422,8 +438,8 @@ public ClientConfigBuilder onDeviceDecisioningHandler(OnDeviceDecisioningHandler } /** - * Default Decisioning Method - * Default value is server-side + * Default Decisioning Method Default value is server-side + * * @param decisioningMethod * @return ClientConfigBuilder */ @@ -433,8 +449,8 @@ public ClientConfigBuilder defaultDecisioningMethod(DecisioningMethod decisionin } /** - * On Device Environment - * Default value is production + * On Device Environment Default value is production + * * @param environment * @return ClientConfigBuilder */ @@ -444,8 +460,8 @@ public ClientConfigBuilder onDeviceEnvironment(String environment) { } /** - * On Device Config Hostname - * Default value is assets.adobetarget.com + * On Device Config Hostname Default value is assets.adobetarget.com + * * @param hostname * @return ClientConfigBuilder */ @@ -455,8 +471,8 @@ public ClientConfigBuilder onDeviceConfigHostname(String hostname) { } /** - * On Device Decisioning Polling Interval in seconds - * Default value is 300 + * On Device Decisioning Polling Interval in seconds Default value is 300 + * * @param pollingInterval * @return ClientConfigBuilder */ @@ -467,6 +483,7 @@ public ClientConfigBuilder onDeviceDecisioningPollingIntSecs(int pollingInterval /** * On Device Artifact Payload + * * @param payload * @return ClientConfigBuilder */ @@ -477,6 +494,7 @@ public ClientConfigBuilder onDeviceArtifactPayload(byte[] payload) { /** * On Device All Matching Rules Mboxes + * * @param mboxes * @return ClientConfigBuilder */ @@ -487,6 +505,7 @@ public ClientConfigBuilder onDeviceAllMatchingRulesMboxes(List mboxes) { /** * HTTP Client + * * @param httpClient * @return ClientConfigBuilder */ @@ -495,6 +514,19 @@ public ClientConfigBuilder httpClient(HttpClient httpClient) { return this; } + /** + * On Device Decisioning - artifact request behind a proxy will include an empty Authorization + * header in order to bypass the proxy's internal cache + * + * @param shouldArtifactRequestBypassProxyCache + * @return ClientConfigBuilder + */ + public ClientConfigBuilder shouldArtifactRequestBypassProxyCache( + boolean shouldArtifactRequestBypassProxyCache) { + this.shouldArtifactRequestBypassProxyCache = shouldArtifactRequestBypassProxyCache; + return this; + } + public ClientConfig build() { ClientConfig clientConfig = new ClientConfig(); Objects.requireNonNull(organizationId, "organization id cannot be null"); @@ -528,6 +560,8 @@ public ClientConfig build() { clientConfig.onDeviceAllMatchingRulesMboxes = this.onDeviceAllMatchingRulesMboxes; clientConfig.telemetryEnabled = this.telemetryEnabled; clientConfig.httpClient = this.httpClient; + clientConfig.shouldArtifactRequestBypassProxyCache = + this.shouldArtifactRequestBypassProxyCache; return clientConfig; } } diff --git a/src/main/java/com/adobe/target/edge/client/ondevice/DefaultRuleLoader.java b/src/main/java/com/adobe/target/edge/client/ondevice/DefaultRuleLoader.java index 5bf6e83..2a681dc 100644 --- a/src/main/java/com/adobe/target/edge/client/ondevice/DefaultRuleLoader.java +++ b/src/main/java/com/adobe/target/edge/client/ondevice/DefaultRuleLoader.java @@ -118,8 +118,9 @@ public synchronized void start( } else { unirestInstance.config().proxy(proxyConfig.getHost(), proxyConfig.getPort()); } - // Bypass proxy-level cache - unirestInstance.config().setDefaultHeader("Authorization", EMPTY_STRING); + if (clientConfig.shouldArtifactRequestBypassProxyCache()) { + unirestInstance.config().setDefaultHeader("Authorization", EMPTY_STRING); + } } } this.clientConfig = clientConfig;