Implementation is thread-safe, and subclasses must be thread-safe. For maximum efficiency,
applications should use a single globally-shared instance of the HTTP transport.
The recommended concrete implementation HTTP transport library to use depends on what
environment you are running in:
Google App Engine: use
com.google.api.client.extensions.appengine.http.UrlFetchTransport.
com.google.api.client.apache.ApacheHttpTransport doesn't work on App Engine
because the Apache HTTP Client opens its own sockets (though in theory there are ways
to hack it to work on App Engine that might work).
com.google.api.client.javanet.NetHttpTransport is discouraged due to a bug in
the App Engine SDK itself in how it parses HTTP headers in the response.
Android:
For maximum backwards compatibility with older SDK's use
newCompatibleTransport from
com.google.api.client.extensions.android.http.AndroidHttp (read its JavaDoc for
details).
If your application is targeting Gingerbread (SDK 2.3) or higher, simply use
com.google.api.client.javanet.NetHttpTransport.
Other Java environments
com.google.api.client.googleapis.javanet.GoogleNetHttpTransport is included
in google-api-cient 1.22.0, so easy to include.
com.google.api.client.javanet.NetHttpTransport is based on the
HttpURLConnection built into the Java SDK, so it used to be the preferred choice.
com.google.api.client.apache.ApacheHttpTransport is a good choice for users
of the Apache HTTP Client, especially if you need some of the configuration options
available in that library.
Some HTTP transports do not support all HTTP methods. Use #supportsMethod(String) to
check if a certain HTTP method is supported. Calling #buildRequest() on a method that is
not supported will result in an IllegalArgumentException.
Subclasses should override #supportsMethod(String) and #buildRequest(String,
String) to build requests and specify which HTTP methods are supported.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class HttpTransport (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpTransport)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.HttpTransport)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.HttpTransport)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.HttpTransport)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.HttpTransport)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.HttpTransport)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.HttpTransport)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.HttpTransport) \n\n public abstract class HttpTransport\n\nThread-safe abstract HTTP transport.\n\nImplementation is thread-safe, and subclasses must be thread-safe. For maximum efficiency,\napplications should use a single globally-shared instance of the HTTP transport.\n\nThe recommended concrete implementation HTTP transport library to use depends on what\nenvironment you are running in:\n\n- Google App Engine: use `\n com.google.api.client.extensions.appengine.http.UrlFetchTransport`.\n - `com.google.api.client.apache.ApacheHttpTransport` doesn't work on App Engine because the Apache HTTP Client opens its own sockets (though in theory there are ways to hack it to work on App Engine that might work).\n - `com.google.api.client.javanet.NetHttpTransport` is discouraged due to a bug in the App Engine SDK itself in how it parses HTTP headers in the response.\n- Android:\n - For maximum backwards compatibility with older SDK's use `\n newCompatibleTransport` from `\n com.google.api.client.extensions.android.http.AndroidHttp` (read its JavaDoc for details).\n - If your application is targeting Gingerbread (SDK 2.3) or higher, simply use `\n com.google.api.client.javanet.NetHttpTransport`.\n- Other Java environments\n - `com.google.api.client.googleapis.javanet.GoogleNetHttpTransport` is included in google-api-cient 1.22.0, so easy to include.\n - `com.google.api.client.javanet.NetHttpTransport` is based on the HttpURLConnection built into the Java SDK, so it used to be the preferred choice.\n - `com.google.api.client.apache.ApacheHttpTransport` is a good choice for users of the Apache HTTP Client, especially if you need some of the configuration options available in that library.\n\nSome HTTP transports do not support all HTTP methods. Use [#supportsMethod(String)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpTransport#com_google_api_client_http_HttpTransport_supportsMethod_java_lang_String_) to\ncheck if a certain HTTP method is supported. Calling [#buildRequest()](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpTransport#com_google_api_client_http_HttpTransport_buildRequest_) on a method that is\nnot supported will result in an IllegalArgumentException.\n\nSubclasses should override [#supportsMethod(String)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpTransport#com_google_api_client_http_HttpTransport_supportsMethod_java_lang_String_) and #buildRequest(String, String) to build requests and specify which HTTP methods are supported. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e HttpTransport \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### HttpTransport()\n\n public HttpTransport()\n\nMethods\n-------\n\n### buildRequest(String method, String url)\n\n protected abstract LowLevelHttpRequest buildRequest(String method, String url)\n\nBuilds a low level HTTP request for the given HTTP method.\n\n### createRequestFactory()\n\n public final HttpRequestFactory createRequestFactory()\n\nReturns a new instance of an HTTP request factory based on this HTTP transport.\n\n### createRequestFactory(HttpRequestInitializer initializer)\n\n public final HttpRequestFactory createRequestFactory(HttpRequestInitializer initializer)\n\nReturns a new instance of an HTTP request factory based on this HTTP transport with the given\nHTTP request initializer.\n\n### isMtls()\n\n public boolean isMtls()\n\nReturns whether the transport is mTLS.\n\n### isShutdown()\n\n public boolean isShutdown()\n\nReturns whether the transport is shutdown or not.\n\n### shutdown()\n\n public void shutdown()\n\nDefault implementation does nothing, but subclasses may override to possibly release allocated\nsystem resources or close connections.\n\n### supportsMethod(String method)\n\n public boolean supportsMethod(String method)\n\nReturns whether a specified HTTP method is supported by this transport.\n\nDefault implementation returns true if and only if the request method is `\"DELETE\"`,\n`\"GET\"`, `\"POST\"`, or `\"PUT\"`. Subclasses should override."]]