diff --git a/framework-platform/framework-platform.gradle b/framework-platform/framework-platform.gradle index 465b485ee4..566e45fd78 100644 --- a/framework-platform/framework-platform.gradle +++ b/framework-platform/framework-platform.gradle @@ -101,8 +101,8 @@ dependencies { api("org.apache.derby:derby:10.16.1.1") api("org.apache.derby:derbyclient:10.16.1.1") api("org.apache.derby:derbytools:10.16.1.1") - api("org.apache.httpcomponents.client5:httpclient5:5.4") - api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3") + api("org.apache.httpcomponents.client5:httpclient5:5.4.1") + api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3.1") api("org.apache.poi:poi-ooxml:5.2.5") api("org.apache.tomcat.embed:tomcat-embed-core:10.1.28") api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.28") diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java index c986bc371d..2b93d88abd 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java @@ -205,7 +205,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest @Override - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") // HttpClientContext.REQUEST_CONFIG public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { HttpClient client = getHttpClient(); @@ -217,9 +217,10 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest } // Request configuration not set in the context - if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) { - // Use request configuration given by the user, when available + if (!(context instanceof HttpClientContext clientContext && clientContext.getRequestConfig() != null) && + context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) { RequestConfig config = null; + // Use request configuration given by the user, when available if (httpRequest instanceof Configurable configurable) { config = configurable.getConfig(); } @@ -227,6 +228,9 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest config = createRequestConfig(client); } if (config != null) { + if (context instanceof HttpClientContext clientContext) { + clientContext.setRequestConfig(config); + } context.setAttribute(HttpClientContext.REQUEST_CONFIG, config); } }