|
|
@ -89,24 +89,25 @@ public final class ClientHttpRequestFactories {
|
|
|
|
* dependencies {@link ClassUtils#isPresent are available} is returned:
|
|
|
|
* dependencies {@link ClassUtils#isPresent are available} is returned:
|
|
|
|
* <ol>
|
|
|
|
* <ol>
|
|
|
|
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link OkHttp3ClientHttpRequestFactory}</li>
|
|
|
|
|
|
|
|
* <li>{@link JettyClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link JettyClientHttpRequestFactory}</li>
|
|
|
|
|
|
|
|
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
|
|
|
|
* <li>{@link SimpleClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link SimpleClientHttpRequestFactory}</li>
|
|
|
|
* </ol>
|
|
|
|
* </ol>
|
|
|
|
* @param settings the settings to apply
|
|
|
|
* @param settings the settings to apply
|
|
|
|
* @return a new {@link ClientHttpRequestFactory}
|
|
|
|
* @return a new {@link ClientHttpRequestFactory}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@SuppressWarnings("removal")
|
|
|
|
public static ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
|
|
|
|
public static ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
|
|
|
|
Assert.notNull(settings, "Settings must not be null");
|
|
|
|
Assert.notNull(settings, "Settings must not be null");
|
|
|
|
if (APACHE_HTTP_CLIENT_PRESENT) {
|
|
|
|
if (APACHE_HTTP_CLIENT_PRESENT) {
|
|
|
|
return HttpComponents.get(settings);
|
|
|
|
return HttpComponents.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (OKHTTP_CLIENT_PRESENT) {
|
|
|
|
|
|
|
|
return OkHttp.get(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (JETTY_CLIENT_PRESENT) {
|
|
|
|
if (JETTY_CLIENT_PRESENT) {
|
|
|
|
return Jetty.get(settings);
|
|
|
|
return Jetty.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OKHTTP_CLIENT_PRESENT) {
|
|
|
|
|
|
|
|
return OkHttp.get(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
return Simple.get(settings);
|
|
|
|
return Simple.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -119,7 +120,7 @@ public final class ClientHttpRequestFactories {
|
|
|
|
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link JdkClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link JdkClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link JettyClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link JettyClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link OkHttp3ClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
|
|
|
|
* <li>{@link SimpleClientHttpRequestFactory}</li>
|
|
|
|
* <li>{@link SimpleClientHttpRequestFactory}</li>
|
|
|
|
* </ul>
|
|
|
|
* </ul>
|
|
|
|
* A {@code requestFactoryType} of {@link ClientHttpRequestFactory} is equivalent to
|
|
|
|
* A {@code requestFactoryType} of {@link ClientHttpRequestFactory} is equivalent to
|
|
|
@ -129,7 +130,7 @@ public final class ClientHttpRequestFactories {
|
|
|
|
* @param settings the settings to apply
|
|
|
|
* @param settings the settings to apply
|
|
|
|
* @return a new {@link ClientHttpRequestFactory} instance
|
|
|
|
* @return a new {@link ClientHttpRequestFactory} instance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings({ "unchecked", "removal" })
|
|
|
|
public static <T extends ClientHttpRequestFactory> T get(Class<T> requestFactoryType,
|
|
|
|
public static <T extends ClientHttpRequestFactory> T get(Class<T> requestFactoryType,
|
|
|
|
ClientHttpRequestFactorySettings settings) {
|
|
|
|
ClientHttpRequestFactorySettings settings) {
|
|
|
|
Assert.notNull(settings, "Settings must not be null");
|
|
|
|
Assert.notNull(settings, "Settings must not be null");
|
|
|
@ -139,9 +140,6 @@ public final class ClientHttpRequestFactories {
|
|
|
|
if (requestFactoryType == HttpComponentsClientHttpRequestFactory.class) {
|
|
|
|
if (requestFactoryType == HttpComponentsClientHttpRequestFactory.class) {
|
|
|
|
return (T) HttpComponents.get(settings);
|
|
|
|
return (T) HttpComponents.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (requestFactoryType == OkHttp3ClientHttpRequestFactory.class) {
|
|
|
|
|
|
|
|
return (T) OkHttp.get(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requestFactoryType == JettyClientHttpRequestFactory.class) {
|
|
|
|
if (requestFactoryType == JettyClientHttpRequestFactory.class) {
|
|
|
|
return (T) Jetty.get(settings);
|
|
|
|
return (T) Jetty.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,6 +149,9 @@ public final class ClientHttpRequestFactories {
|
|
|
|
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
|
|
|
|
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
|
|
|
|
return (T) Simple.get(settings);
|
|
|
|
return (T) Simple.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requestFactoryType == OkHttp3ClientHttpRequestFactory.class) {
|
|
|
|
|
|
|
|
return (T) OkHttp.get(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
return get(() -> createRequestFactory(requestFactoryType), settings);
|
|
|
|
return get(() -> createRequestFactory(requestFactoryType), settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -220,6 +221,8 @@ public final class ClientHttpRequestFactories {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Support for {@link OkHttp3ClientHttpRequestFactory}.
|
|
|
|
* Support for {@link OkHttp3ClientHttpRequestFactory}.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Deprecated(since = "3.2.0", forRemoval = true)
|
|
|
|
|
|
|
|
@SuppressWarnings("removal")
|
|
|
|
static class OkHttp {
|
|
|
|
static class OkHttp {
|
|
|
|
|
|
|
|
|
|
|
|
static OkHttp3ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
|
|
|
|
static OkHttp3ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
|
|
|
|