Class NetHttpTransport
java.lang.Object
com.google.api.client.http.HttpTransport
com.google.api.client.http.javanet.NetHttpTransport
Thread-safe HTTP low-level transport based on the
java.net
package.
Users should consider modifying the keep alive property on NetHttpTransport
to 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConnectionFactory
private final HostnameVerifier
Host name verifier ornull
for the default.private final boolean
Whether the transport is mTLS.private static final String
private final SSLSocketFactory
SSL socket factory ornull
for the default.private static final String[]
All valid request methods as specified inHttpURLConnection.setRequestMethod(java.lang.String)
, sorted in ascending alphabetical order. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with the default behavior.NetHttpTransport
(ConnectionFactory connectionFactory, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, boolean isMtls) NetHttpTransport
(Proxy proxy, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, boolean isMtls) -
Method Summary
Modifier and TypeMethodDescriptionprotected NetHttpRequest
buildRequest
(String method, String url) Builds a low level HTTP request for the given HTTP method.private static Proxy
private ConnectionFactory
getConnectionFactory
(ConnectionFactory connectionFactory) boolean
isMtls()
Returns whether the transport is mTLS.boolean
supportsMethod
(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 Details
-
SUPPORTED_METHODS
All valid request methods as specified inHttpURLConnection.setRequestMethod(java.lang.String)
, sorted in ascending alphabetical order. -
SHOULD_USE_PROXY_FLAG
- See Also:
-
connectionFactory
-
sslSocketFactory
SSL socket factory ornull
for the default. -
hostnameVerifier
Host name verifier ornull
for the default. -
isMtls
private final boolean isMtlsWhether the transport is mTLS. Default value isfalse
.
-
-
Constructor Details
-
NetHttpTransport
public NetHttpTransport()Constructor with the default behavior.Instead use
NetHttpTransport.Builder
to modify behavior. -
NetHttpTransport
NetHttpTransport(Proxy proxy, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, boolean isMtls) - Parameters:
proxy
- HTTP proxy ornull
to use the proxy settings from system propertiessslSocketFactory
- SSL socket factory ornull
for the defaulthostnameVerifier
- host name verifier ornull
for the defaultisMtls
- Whether the transport is mTLS. Default value isfalse
- Since:
- 1.38
-
NetHttpTransport
NetHttpTransport(ConnectionFactory connectionFactory, SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier, boolean isMtls) - Parameters:
connectionFactory
- factory to produce connections fromURL
s; ifnull
thenDefaultConnectionFactory
is usedsslSocketFactory
- SSL socket factory ornull
for the defaulthostnameVerifier
- host name verifier ornull
for the defaultisMtls
- Whether the transport is mTLS. Default value isfalse
- Since:
- 1.38
-
-
Method Details
-
defaultProxy
-
getConnectionFactory
-
supportsMethod
Description copied from class:HttpTransport
Returns 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:
supportsMethod
in classHttpTransport
- Parameters:
method
- HTTP method
-
isMtls
public boolean isMtls()Description copied from class:HttpTransport
Returns whether the transport is mTLS.- Overrides:
isMtls
in classHttpTransport
- Returns:
- boolean indicating if the transport is mTLS.
-
buildRequest
Description copied from class:HttpTransport
Builds a low level HTTP request for the given HTTP method.- Specified by:
buildRequest
in classHttpTransport
- Parameters:
method
- HTTP methodurl
- URL- Returns:
- new low level HTTP request
- Throws:
IOException
-