Class NetHttpTransport
- java.lang.Object
-
- com.google.api.client.http.HttpTransport
-
- com.google.api.client.http.javanet.NetHttpTransport
-
public final class NetHttpTransport extends HttpTransport
Thread-safe HTTP low-level transport based on thejava.netpackage.Users should consider modifying the keep alive property on
NetHttpTransportto control whether the socket should be returned to a pool of connected sockets. More information is available here.We honor the default global caching behavior. To change the default behavior use
URLConnection.setDefaultUseCaches(boolean).Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNetHttpTransport.BuilderBuilder forNetHttpTransport.
-
Field Summary
Fields Modifier and Type Field Description private ConnectionFactoryconnectionFactoryprivate javax.net.ssl.HostnameVerifierhostnameVerifierHost name verifier ornullfor the default.private booleanisMtlsWhether the transport is mTLS.private static java.lang.StringSHOULD_USE_PROXY_FLAGprivate javax.net.ssl.SSLSocketFactorysslSocketFactorySSL socket factory ornullfor the default.private static java.lang.String[]SUPPORTED_METHODSAll valid request methods as specified inHttpURLConnection.setRequestMethod(java.lang.String), sorted in ascending alphabetical order.
-
Constructor Summary
Constructors Constructor Description NetHttpTransport()Constructor with the default behavior.NetHttpTransport(ConnectionFactory connectionFactory, javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean isMtls)NetHttpTransport(java.net.Proxy proxy, javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean isMtls)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NetHttpRequestbuildRequest(java.lang.String method, java.lang.String url)Builds a low level HTTP request for the given HTTP method.private static java.net.ProxydefaultProxy()private ConnectionFactorygetConnectionFactory(ConnectionFactory connectionFactory)booleanisMtls()Returns whether the transport is mTLS.booleansupportsMethod(java.lang.String method)Returns whether a specified HTTP method is supported by this transport.-
Methods inherited from class com.google.api.client.http.HttpTransport
createRequestFactory, createRequestFactory, isShutdown, shutdown
-
-
-
-
Field Detail
-
SUPPORTED_METHODS
private static final java.lang.String[] SUPPORTED_METHODS
All valid request methods as specified inHttpURLConnection.setRequestMethod(java.lang.String), sorted in ascending alphabetical order.
-
SHOULD_USE_PROXY_FLAG
private static final java.lang.String SHOULD_USE_PROXY_FLAG
- See Also:
- Constant Field Values
-
connectionFactory
private final ConnectionFactory connectionFactory
-
sslSocketFactory
private final javax.net.ssl.SSLSocketFactory sslSocketFactory
SSL socket factory ornullfor the default.
-
hostnameVerifier
private final javax.net.ssl.HostnameVerifier hostnameVerifier
Host name verifier ornullfor the default.
-
isMtls
private final boolean isMtls
Whether the transport is mTLS. Default value isfalse.
-
-
Constructor Detail
-
NetHttpTransport
public NetHttpTransport()
Constructor with the default behavior.Instead use
NetHttpTransport.Builderto modify behavior.
-
NetHttpTransport
NetHttpTransport(java.net.Proxy proxy, javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean isMtls)- Parameters:
proxy- HTTP proxy ornullto use the proxy settings from system propertiessslSocketFactory- SSL socket factory ornullfor the defaulthostnameVerifier- host name verifier ornullfor the defaultisMtls- Whether the transport is mTLS. Default value isfalse- Since:
- 1.38
-
NetHttpTransport
NetHttpTransport(ConnectionFactory connectionFactory, javax.net.ssl.SSLSocketFactory sslSocketFactory, javax.net.ssl.HostnameVerifier hostnameVerifier, boolean isMtls)
- Parameters:
connectionFactory- factory to produce connections fromURLs; ifnullthenDefaultConnectionFactoryis usedsslSocketFactory- SSL socket factory ornullfor the defaulthostnameVerifier- host name verifier ornullfor the defaultisMtls- Whether the transport is mTLS. Default value isfalse- Since:
- 1.38
-
-
Method Detail
-
defaultProxy
private static java.net.Proxy defaultProxy()
-
getConnectionFactory
private ConnectionFactory getConnectionFactory(ConnectionFactory connectionFactory)
-
supportsMethod
public boolean supportsMethod(java.lang.String method)
Description copied from class:HttpTransportReturns whether a specified HTTP method is supported by this transport.Default implementation returns true if and only if the request method is
"DELETE","GET","POST", or"PUT". Subclasses should override.- Overrides:
supportsMethodin classHttpTransport- Parameters:
method- HTTP method
-
isMtls
public boolean isMtls()
Description copied from class:HttpTransportReturns whether the transport is mTLS.- Overrides:
isMtlsin classHttpTransport- Returns:
- boolean indicating if the transport is mTLS.
-
buildRequest
protected NetHttpRequest buildRequest(java.lang.String method, java.lang.String url) throws java.io.IOException
Description copied from class:HttpTransportBuilds a low level HTTP request for the given HTTP method.- Specified by:
buildRequestin classHttpTransport- Parameters:
method- HTTP methodurl- URL- Returns:
- new low level HTTP request
- Throws:
java.io.IOException
-
-