Skip to content

Commit 11ebcee

Browse files
committed
Call get/setRequestConfig for HttpClient 5.4 compatibility
Includes upgrade to HttpClient 5.4.1 while retaining a HttpClient 5.1 baseline. Closes gh-33806
1 parent fa21dff commit 11ebcee

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: framework-platform/framework-platform.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ dependencies {
101101
api("org.apache.derby:derby:10.16.1.1")
102102
api("org.apache.derby:derbyclient:10.16.1.1")
103103
api("org.apache.derby:derbytools:10.16.1.1")
104-
api("org.apache.httpcomponents.client5:httpclient5:5.4")
105-
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3")
104+
api("org.apache.httpcomponents.client5:httpclient5:5.4.1")
105+
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3.1")
106106
api("org.apache.poi:poi-ooxml:5.2.5")
107107
api("org.apache.tomcat.embed:tomcat-embed-core:10.1.28")
108108
api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.28")

Diff for: spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void setHttpContextFactory(BiFunction<HttpMethod, URI, HttpContext> httpC
205205

206206

207207
@Override
208-
@SuppressWarnings("deprecation")
208+
@SuppressWarnings("deprecation") // HttpClientContext.REQUEST_CONFIG
209209
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
210210
HttpClient client = getHttpClient();
211211

@@ -217,16 +217,20 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
217217
}
218218

219219
// Request configuration not set in the context
220-
if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
221-
// Use request configuration given by the user, when available
220+
if (!(context instanceof HttpClientContext clientContext && clientContext.getRequestConfig() != null) &&
221+
context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
222222
RequestConfig config = null;
223+
// Use request configuration given by the user, when available
223224
if (httpRequest instanceof Configurable configurable) {
224225
config = configurable.getConfig();
225226
}
226227
if (config == null) {
227228
config = createRequestConfig(client);
228229
}
229230
if (config != null) {
231+
if (context instanceof HttpClientContext clientContext) {
232+
clientContext.setRequestConfig(config);
233+
}
230234
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
231235
}
232236
}

0 commit comments

Comments
 (0)