|
|
@ -49,6 +49,7 @@ import org.springframework.boot.ssl.SslOptions;
|
|
|
|
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
|
|
|
|
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
|
|
|
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
|
|
|
|
|
import org.springframework.http.client.JdkClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.JettyClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.JettyClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
|
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
|
@ -126,6 +127,9 @@ public final class ClientHttpRequestFactories {
|
|
|
|
if (requestFactoryType == JettyClientHttpRequestFactory.class) {
|
|
|
|
if (requestFactoryType == JettyClientHttpRequestFactory.class) {
|
|
|
|
return (T) Jetty.get(settings);
|
|
|
|
return (T) Jetty.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requestFactoryType == JdkClientHttpRequestFactory.class) {
|
|
|
|
|
|
|
|
return (T) Jdk.get(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
|
|
|
|
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
|
|
|
|
return (T) Simple.get(settings);
|
|
|
|
return (T) Simple.get(settings);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -254,6 +258,32 @@ public final class ClientHttpRequestFactories {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Support for {@link JdkClientHttpRequestFactory}.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static class Jdk {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JdkClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
|
|
|
|
|
|
|
|
java.net.http.HttpClient httpClient = createHttpClient(settings.connectTimeout(), settings.sslBundle());
|
|
|
|
|
|
|
|
JdkClientHttpRequestFactory requestFactory = new JdkClientHttpRequestFactory(httpClient);
|
|
|
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
|
|
|
|
map.from(settings::readTimeout).asInt(Duration::toMillis).to(requestFactory::setReadTimeout);
|
|
|
|
|
|
|
|
return requestFactory;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static java.net.http.HttpClient createHttpClient(Duration connectTimeout, SslBundle sslBundle) {
|
|
|
|
|
|
|
|
java.net.http.HttpClient.Builder builder = java.net.http.HttpClient.newBuilder();
|
|
|
|
|
|
|
|
if (connectTimeout != null) {
|
|
|
|
|
|
|
|
builder.connectTimeout(connectTimeout);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sslBundle != null) {
|
|
|
|
|
|
|
|
builder.sslContext(sslBundle.createSslContext());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return builder.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Support for {@link SimpleClientHttpRequestFactory}.
|
|
|
|
* Support for {@link SimpleClientHttpRequestFactory}.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|