Merge branch '6.1.x'

This commit is contained in:
Juergen Hoeller
2024-10-29 23:04:05 +01:00
6 changed files with 71 additions and 13 deletions

View File

@@ -237,7 +237,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();
@@ -249,9 +249,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();
}
@@ -259,6 +260,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);
}
}