Class NetHttpTransport (1.45.0)

public final class NetHttpTransport extends HttpTransport

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 HttpURLConnection#setDefaultUseCaches(boolean).

Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.

Inheritance

java.lang.Object > HttpTransport > NetHttpTransport

Constructors

NetHttpTransport()

public NetHttpTransport()

Constructor with the default behavior.

Instead use Builder to modify behavior.

Methods

buildRequest(String method, String url)

protected NetHttpRequest buildRequest(String method, String url)

Builds a low level HTTP request for the given HTTP method.

Parameters
Name Description
method String
url String
Returns
Type Description
com.google.api.client.http.javanet.NetHttpRequest
Overrides
Exceptions
Type Description
IOException

isMtls()

public boolean isMtls()

Returns whether the transport is mTLS.

Returns
Type Description
boolean
Overrides

supportsMethod(String method)

public boolean supportsMethod(String method)

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.

Parameter
Name Description
method String
Returns
Type Description
boolean
Overrides