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)
Builds a low level HTTP request for the given HTTP method.
|
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)
Returns whether a specified HTTP method is supported by this transport.
|
createRequestFactory, createRequestFactory
public 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)
HttpTransport
Default implementation returns true if and only if the request method is "DELETE"
,
"GET"
, "POST"
, or "PUT"
. Subclasses should override.
supportsMethod
in class HttpTransport
method
- HTTP methodprotected com.google.api.client.http.apache.v2.ApacheHttpRequest buildRequest(String method, String url)
HttpTransport
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLpublic void shutdown() throws IOException
shutdown
in class HttpTransport
IOException
- I/O exceptionpublic org.apache.http.client.HttpClient getHttpClient()
public boolean isMtls()
isMtls
in class HttpTransport
Copyright © 2011–2020 Google. All rights reserved.