diff --git a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java index 85f92c0db..84e721d0c 100644 --- a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java +++ b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java @@ -98,7 +98,7 @@ public class RequestAddCookies implements HttpRequestInterceptor { } // Obtain the registry of cookie specs - CookieSpecRegistry registry= (CookieSpecRegistry) context.getAttribute( + CookieSpecRegistry registry = (CookieSpecRegistry) context.getAttribute( ClientContext.COOKIESPEC_REGISTRY); if (registry == null) { this.log.info("CookieSpec registry not available in HTTP context"); diff --git a/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java b/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java index 1760770fa..8e85a57c6 100644 --- a/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java +++ b/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java @@ -76,6 +76,12 @@ public class ResponseProcessCookies implements HttpResponseInterceptor { throw new IllegalArgumentException("HTTP context may not be null"); } + // Obtain actual CookieSpec instance + CookieSpec cookieSpec = (CookieSpec) context.getAttribute( + ClientContext.COOKIE_SPEC); + if (cookieSpec == null) { + return; + } // Obtain cookie store CookieStore cookieStore = (CookieStore) context.getAttribute( ClientContext.COOKIE_STORE); @@ -83,13 +89,6 @@ public class ResponseProcessCookies implements HttpResponseInterceptor { this.log.info("Cookie store not available in HTTP context"); return; } - // Obtain actual CookieSpec instance - CookieSpec cookieSpec = (CookieSpec) context.getAttribute( - ClientContext.COOKIE_SPEC); - if (cookieSpec == null) { - this.log.info("CookieSpec not available in HTTP context"); - return; - } // Obtain actual CookieOrigin instance CookieOrigin cookieOrigin = (CookieOrigin) context.getAttribute( ClientContext.COOKIE_ORIGIN);