public final class ApacheHttpTransport extends HttpTransport
Implementation is thread-safe, as long as any parameter modification to the Apache HTTP Client is only done at initialization time. For maximum efficiency,
applications should use a single globally-shared instance of the HTTP transport.
Default settings are specified in newDefaultHttpClient(). Use the ApacheHttpTransport(HttpClient) constructor to override the Apache HTTP Client used. Please
read the
Apache HTTP Client connection management tutorial for more complex configuration options.
| Constructor and Description |
|---|
ApacheHttpTransport()
Constructor that uses
newDefaultHttpClient() for the Apache HTTP client. |
ApacheHttpTransport(org.apache.http.client.HttpClient httpClient)
Constructor that allows an alternative Apache HTTP client to be used.
|
ApacheHttpTransport(org.apache.http.client.HttpClient httpClient,
boolean isMtls)
Beta Constructor that allows an alternative Apache HTTP client to be used. |
| Modifier and Type | Method and Description |
|---|---|
protected com.google.api.client.http.apache.v2.ApacheHttpRequest |
buildRequest(String method,
String url) |
org.apache.http.client.HttpClient |
getHttpClient()
Returns the Apache HTTP client.
|
boolean |
isMtls()
Returns if the underlying HTTP client is mTLS.
|
static org.apache.http.client.HttpClient |
newDefaultHttpClient()
Creates a new instance of the Apache HTTP client that is used by the
ApacheHttpTransport() constructor. |
static org.apache.http.impl.client.HttpClientBuilder |
newDefaultHttpClientBuilder()
Creates a new Apache HTTP client builder that is used by the
ApacheHttpTransport()
constructor. |
void |
shutdown()
Shuts down the connection manager and releases allocated resources.
|
boolean |
supportsMethod(String method) |
createRequestFactory, createRequestFactory, isShutdownpublic ApacheHttpTransport()
newDefaultHttpClient() for the Apache HTTP client.public ApacheHttpTransport(org.apache.http.client.HttpClient httpClient)
Note that in the previous version, we overrode several settings. However, we are no longer able to do so.
If you choose to provide your own Apache HttpClient implementation, be sure that
httpClient - Apache HTTP client to use@Beta public ApacheHttpTransport(org.apache.http.client.HttpClient httpClient, boolean isMtls)
Beta Note that in the previous version, we overrode several settings. However, we are no longer able to do so.
If you choose to provide your own Apache HttpClient implementation, be sure that
httpClient - Apache HTTP client to useisMtls - If the HTTP client is mutual TLSpublic static org.apache.http.client.HttpClient newDefaultHttpClient()
ApacheHttpTransport() constructor.
Settings:
PoolingHttpClientConnectionManager.
SystemDefaultRoutePlanner with ProxySelector.getDefault(), which uses the proxy settings from system
properties.
public static org.apache.http.impl.client.HttpClientBuilder newDefaultHttpClientBuilder()
ApacheHttpTransport()
constructor.
Settings:
PoolingHttpClientConnectionManager.
SystemDefaultRoutePlanner with ProxySelector.getDefault(), which uses the proxy settings from system
properties.
public boolean supportsMethod(String method)
supportsMethod in class HttpTransportprotected com.google.api.client.http.apache.v2.ApacheHttpRequest buildRequest(String method, String url)
buildRequest in class HttpTransportpublic void shutdown()
throws IOException
shutdown in class HttpTransportIOExceptionpublic org.apache.http.client.HttpClient getHttpClient()
public boolean isMtls()
isMtls in class HttpTransportCopyright © 2011–2025 Google. All rights reserved.