public final class UrlFetchTransport extends HttpTransport
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
URL Fetch is only available on Google App Engine (not on any other Java environment), and is
the underlying HTTP transport used for App Engine. Their implementation of HttpURLConnection
is simply an abstraction layer on top of URL Fetch. By implementing a
transport that directly uses URL Fetch, we can optimize the behavior slightly, and can
potentially take advantage of features in URL Fetch that are not available in HttpURLConnection
. Furthermore, there is currently a serious bug in how HTTP headers are
processed in the App Engine implementation of HttpURLConnection
, which we are able to
avoid using this implementation. Therefore, this is the recommended transport to use on App
Engine.
Modifier and Type | Class and Description |
---|---|
static class |
UrlFetchTransport.Builder
Builder for
UrlFetchTransport . |
Constructor and Description |
---|
UrlFetchTransport()
Constructor with the default fetch options.
|
Modifier and Type | Method and Description |
---|---|
protected com.google.api.client.extensions.appengine.http.UrlFetchRequest |
buildRequest(String method,
String url)
Builds a low level HTTP request for the given HTTP method.
|
static UrlFetchTransport |
getDefaultInstance()
Returns a global thread-safe instance.
|
boolean |
supportsMethod(String method)
Returns whether a specified HTTP method is supported by this transport.
|
createRequestFactory, createRequestFactory, isMtls, shutdown
public UrlFetchTransport()
Use UrlFetchTransport.Builder
to modify fetch options.
public static UrlFetchTransport getDefaultInstance()
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.extensions.appengine.http.UrlFetchRequest buildRequest(String method, String url) throws IOException
HttpTransport
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLIOException
Copyright © 2011–2022 Google. All rights reserved.