Merge branch '6.2.x'
This commit is contained in:
commit
4a99fa8846
|
@ -235,9 +235,8 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||||
context = HttpClientContext.create();
|
context = HttpClientContext.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request configuration not set in the context
|
// No custom request configuration was set
|
||||||
if (!(context instanceof HttpClientContext clientContext && clientContext.getRequestConfig() != null) &&
|
if (!hasCustomRequestConfig(context)) {
|
||||||
context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
|
|
||||||
RequestConfig config = null;
|
RequestConfig config = null;
|
||||||
// Use request configuration given by the user, when available
|
// Use request configuration given by the user, when available
|
||||||
if (httpRequest instanceof Configurable configurable) {
|
if (httpRequest instanceof Configurable configurable) {
|
||||||
|
@ -256,6 +255,18 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
|
||||||
return new HttpComponentsClientHttpRequest(client, httpRequest, context);
|
return new HttpComponentsClientHttpRequest(client, httpRequest, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") // HttpClientContext.REQUEST_CONFIG
|
||||||
|
private static boolean hasCustomRequestConfig(HttpContext context) {
|
||||||
|
if (context instanceof HttpClientContext clientContext) {
|
||||||
|
// Prior to 5.4, the default config was set to RequestConfig.DEFAULT
|
||||||
|
// As of 5.4, it is set to null
|
||||||
|
RequestConfig requestConfig = clientContext.getRequestConfig();
|
||||||
|
return requestConfig != null && !requestConfig.equals(RequestConfig.DEFAULT);
|
||||||
|
}
|
||||||
|
// Prior to 5.4, the config was stored as an attribute
|
||||||
|
return context.getAttribute(HttpClientContext.REQUEST_CONFIG) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a default {@link RequestConfig} to use with the given client.
|
* Create a default {@link RequestConfig} to use with the given client.
|
||||||
|
|
Loading…
Reference in New Issue