in src/main/java/software/amazon/awssdk/crt/http/HttpClientConnectionManager.java [46:140]
private HttpClientConnectionManager(HttpClientConnectionManagerOptions options) {
URI uri = options.getUri();
if (uri == null) { throw new IllegalArgumentException("URI must not be null"); }
if (uri.getScheme() == null) { throw new IllegalArgumentException("URI does not have a Scheme"); }
if (!HTTP.equals(uri.getScheme()) && !HTTPS.equals(uri.getScheme())) { throw new IllegalArgumentException("URI has unknown Scheme"); }
if (uri.getHost() == null) { throw new IllegalArgumentException("URI does not have a Host name"); }
ClientBootstrap clientBootstrap = options.getClientBootstrap();
if (clientBootstrap == null) { throw new IllegalArgumentException("ClientBootstrap must not be null"); }
SocketOptions socketOptions = options.getSocketOptions();
if (socketOptions == null) { throw new IllegalArgumentException("SocketOptions must not be null"); }
boolean useTls = HTTPS.equals(uri.getScheme());
TlsContext tlsContext = options.getTlsContext();
if (useTls && tlsContext == null) { throw new IllegalArgumentException("TlsContext must not be null if https is used"); }
int windowSize = options.getWindowSize();
if (windowSize <= 0) { throw new IllegalArgumentException("Window Size must be greater than zero."); }
int bufferSize = options.getBufferSize();
if (bufferSize <= 0) { throw new IllegalArgumentException("Buffer Size must be greater than zero."); }
int maxConnections = options.getMaxConnections();
if (maxConnections <= 0) { throw new IllegalArgumentException("Max Connections must be greater than zero."); }
int port = options.getPort();
if (port == -1) {
port = uri.getPort();
/* Pick a default port based on the scheme if one wasn't set */
if (port == -1) {
if (HTTP.equals(uri.getScheme())) { port = DEFAULT_HTTP_PORT; }
if (HTTPS.equals(uri.getScheme())) { port = DEFAULT_HTTPS_PORT; }
}
}
HttpProxyOptions proxyOptions = options.getProxyOptions();
this.windowSize = windowSize;
this.uri = uri;
this.port = port;
this.maxConnections = maxConnections;
int proxyConnectionType = 0;
String proxyHost = null;
int proxyPort = 0;
TlsContext proxyTlsContext = null;
int proxyAuthorizationType = 0;
String proxyAuthorizationUsername = null;
String proxyAuthorizationPassword = null;
if (proxyOptions != null) {
proxyConnectionType = proxyOptions.getConnectionType().getValue();
proxyHost = proxyOptions.getHost();
proxyPort = proxyOptions.getPort();
proxyTlsContext = proxyOptions.getTlsContext();
proxyAuthorizationType = proxyOptions.getAuthorizationType().getValue();
proxyAuthorizationUsername = proxyOptions.getAuthorizationUsername();
proxyAuthorizationPassword = proxyOptions.getAuthorizationPassword();
}
HttpMonitoringOptions monitoringOptions = options.getMonitoringOptions();
long monitoringThroughputThresholdInBytesPerSecond = 0;
int monitoringFailureIntervalInSeconds = 0;
if (monitoringOptions != null) {
monitoringThroughputThresholdInBytesPerSecond = monitoringOptions.getMinThroughputBytesPerSecond();
monitoringFailureIntervalInSeconds = monitoringOptions.getAllowableThroughputFailureIntervalSeconds();
}
acquireNativeHandle(httpClientConnectionManagerNew(this,
clientBootstrap.getNativeHandle(),
socketOptions.getNativeHandle(),
useTls ? tlsContext.getNativeHandle() : 0,
windowSize,
uri.getHost().getBytes(UTF8),
port,
maxConnections,
proxyConnectionType,
proxyHost != null ? proxyHost.getBytes(UTF8) : null,
proxyPort,
proxyTlsContext != null ? proxyTlsContext.getNativeHandle() : 0,
proxyAuthorizationType,
proxyAuthorizationUsername != null ? proxyAuthorizationUsername.getBytes(UTF8) : null,
proxyAuthorizationPassword != null ? proxyAuthorizationPassword.getBytes(UTF8) : null,
options.isManualWindowManagement(),
options.getMaxConnectionIdleInMilliseconds(),
monitoringThroughputThresholdInBytesPerSecond,
monitoringFailureIntervalInSeconds));
/* we don't need to add a reference to socketOptions since it's copied during connection manager construction */
addReferenceTo(clientBootstrap);
if (useTls) {
addReferenceTo(tlsContext);
}
}