@ -17,17 +17,19 @@
package org.springframework.boot.buildpack.platform.docker.transport ;
package org.springframework.boot.buildpack.platform.docker.transport ;
import java.net.URISyntaxException ;
import java.net.URISyntaxException ;
import java.util.concurrent.TimeUnit ;
import javax.net.ssl.SSLContext ;
import javax.net.ssl.SSLContext ;
import org.apache.hc.client5.http.classic.HttpClient ;
import org.apache.hc.client5.http.classic.HttpClient ;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder ;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder ;
import org.apache.hc.client5.http.impl.classic.HttpClients ;
import org.apache.hc.client5.http.impl.classic.HttpClients ;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager ;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder ;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder ;
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory ;
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory ;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory ;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory ;
import org.apache.hc.core5.http.HttpHost ;
import org.apache.hc.core5.http.HttpHost ;
import org.apache.hc.core5.http.io.SocketConfig ;
import org.apache.hc.core5.util.Timeout ;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerHost ;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerHost ;
import org.springframework.boot.buildpack.platform.docker.configuration.ResolvedDockerHost ;
import org.springframework.boot.buildpack.platform.docker.configuration.ResolvedDockerHost ;
@ -42,6 +44,8 @@ import org.springframework.util.Assert;
* /
* /
final class RemoteHttpClientTransport extends HttpClientTransport {
final class RemoteHttpClientTransport extends HttpClientTransport {
private static final Timeout SOCKET_TIMEOUT = Timeout . of ( 30 , TimeUnit . MINUTES ) ;
private RemoteHttpClientTransport ( HttpClient client , HttpHost host ) {
private RemoteHttpClientTransport ( HttpClient client , HttpHost host ) {
super ( client , host ) ;
super ( client , host ) ;
}
}
@ -65,13 +69,15 @@ final class RemoteHttpClientTransport extends HttpClientTransport {
private static RemoteHttpClientTransport create ( DockerHost host , SslContextFactory sslContextFactory ,
private static RemoteHttpClientTransport create ( DockerHost host , SslContextFactory sslContextFactory ,
HttpHost tcpHost ) {
HttpHost tcpHost ) {
HttpClientBuilder builder = HttpClients . custom ( ) ;
SocketConfig socketConfig = SocketConfig . copy ( SocketConfig . DEFAULT ) . setSoTimeout ( SOCKET_TIMEOUT ) . build ( ) ;
PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder
. create ( )
. setDefaultSocketConfig ( socketConfig ) ;
if ( host . isSecure ( ) ) {
if ( host . isSecure ( ) ) {
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder . create ( )
connectionManagerBuilder . setSSLSocketFactory ( getSecureConnectionSocketFactory ( host , sslContextFactory ) ) ;
. setSSLSocketFactory ( getSecureConnectionSocketFactory ( host , sslContextFactory ) )
. build ( ) ;
builder . setConnectionManager ( connectionManager ) ;
}
}
HttpClientBuilder builder = HttpClients . custom ( ) ;
builder . setConnectionManager ( connectionManagerBuilder . build ( ) ) ;
String scheme = host . isSecure ( ) ? "https" : "http" ;
String scheme = host . isSecure ( ) ? "https" : "http" ;
HttpHost httpHost = new HttpHost ( scheme , tcpHost . getHostName ( ) , tcpHost . getPort ( ) ) ;
HttpHost httpHost = new HttpHost ( scheme , tcpHost . getHostName ( ) , tcpHost . getPort ( ) ) ;
return new RemoteHttpClientTransport ( builder . build ( ) , httpHost ) ;
return new RemoteHttpClientTransport ( builder . build ( ) , httpHost ) ;