HttpTransport instead.@Deprecated public class JsonHttpClient extends Object
Implementation is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonHttpClient.Builder
Deprecated.
(scheduled to be removed in 1.14) Use
HttpTransport instead. |
| Modifier | Constructor and Description |
|---|---|
|
JsonHttpClient(HttpTransport transport,
JsonFactory jsonFactory,
String baseUrl)
Deprecated.
Constructor with required parameters.
|
|
JsonHttpClient(HttpTransport transport,
JsonFactory jsonFactory,
String rootUrl,
String servicePath,
HttpRequestInitializer httpRequestInitializer)
Deprecated.
Constructor with required parameters.
|
protected |
JsonHttpClient(HttpTransport transport,
JsonHttpRequestInitializer jsonHttpRequestInitializer,
HttpRequestInitializer httpRequestInitializer,
JsonFactory jsonFactory,
JsonObjectParser jsonObjectParser,
String baseUrl,
String applicationName)
Deprecated.
Construct the
JsonHttpClient. |
protected |
JsonHttpClient(HttpTransport transport,
JsonHttpRequestInitializer jsonHttpRequestInitializer,
HttpRequestInitializer httpRequestInitializer,
JsonFactory jsonFactory,
JsonObjectParser jsonObjectParser,
String rootUrl,
String servicePath,
String applicationName)
Deprecated.
Construct the
JsonHttpClient. |
protected |
JsonHttpClient(HttpTransport transport,
JsonHttpRequestInitializer jsonHttpRequestInitializer,
HttpRequestInitializer httpRequestInitializer,
JsonFactory jsonFactory,
String baseUrl,
String applicationName)
Deprecated.
Construct the
JsonHttpClient. |
| Modifier and Type | Method and Description |
|---|---|
protected HttpRequest |
buildHttpRequest(HttpMethod method,
GenericUrl url,
Object body)
Deprecated.
Create an
HttpRequest suitable for use against this service. |
protected JsonHttpParser |
createParser()
Deprecated.
Creates a JSON parser.
|
protected JsonHttpContent |
createSerializer(Object body)
Deprecated.
Create a JSON serializer for a request object.
|
protected InputStream |
executeAsInputStream(HttpMethod method,
GenericUrl url,
Object body)
Deprecated.
Builds and executes an
HttpRequest and then returns the content input stream of
HttpResponse. |
protected HttpResponse |
executeUnparsed(HttpMethod method,
GenericUrl url,
Object body)
Deprecated.
Builds and executes a
HttpRequest. |
protected HttpResponse |
executeUnparsed(HttpRequest request)
Deprecated.
Executes the specified
HttpRequest. |
String |
getApplicationName()
Deprecated.
Returns the application name to be sent in the User-Agent header of each request or
null for none. |
String |
getBaseUrl()
Deprecated.
Returns the base URL of the service, for example
"https://www.googleapis.com/tasks/v1/"
. |
JsonFactory |
getJsonFactory()
Deprecated.
Returns the JSON Factory.
|
JsonHttpParser |
getJsonHttpParser()
Deprecated.
Returns the JSON HTTP Parser.
|
JsonHttpRequestInitializer |
getJsonHttpRequestInitializer()
Deprecated.
Returns the JSON HTTP request initializer or
null for none. |
JsonObjectParser |
getJsonObjectParser()
Deprecated.
Returns the JSON Object Parser.
|
HttpRequestFactory |
getRequestFactory()
Deprecated.
Returns the HTTP request factory.
|
String |
getRootUrl()
Deprecated.
Returns the root URL of the service, for example
https://www.googleapis.com/. |
String |
getServicePath()
Deprecated.
Returns the service path of the service, for example
"tasks/v1/". |
protected void |
initialize(JsonHttpRequest jsonHttpRequest)
Deprecated.
Initializes a
JsonHttpRequest using a JsonHttpRequestInitializer. |
protected boolean |
isBaseUrlUsed()
Deprecated.
Returns if baseUrl is used instead of
servicePath and rootUrl. |
public JsonHttpClient(HttpTransport transport, JsonFactory jsonFactory, String baseUrl)
Use JsonHttpClient.Builder if you need to specify any of the optional parameters.
transport - The transport to use for requestsjsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"public JsonHttpClient(HttpTransport transport, JsonFactory jsonFactory, String rootUrl, String servicePath, HttpRequestInitializer httpRequestInitializer)
Use JsonHttpClient.Builder if you need to specify any of the optional parameters.
transport - The transport to use for requestsjsonFactory - A factory for creating JSON parsers and serializersrootUrl - The root URL of the serviceservicePath - The service path of the service. It is allowed to be an empty string
"" or a forward slash "/", if it is a forward slash then it is treated
as an empty stringhttpRequestInitializer - The HTTP request initializer or null for noneprotected JsonHttpClient(HttpTransport transport, JsonHttpRequestInitializer jsonHttpRequestInitializer, HttpRequestInitializer httpRequestInitializer, JsonFactory jsonFactory, String baseUrl, String applicationName)
JsonHttpClient.transport - The transport to use for requestsjsonHttpRequestInitializer - The initializer to use when creating an
JsonHttpRequest or null for nonehttpRequestInitializer - The initializer to use when creating an HttpRequest or
null for nonejsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"applicationName - The application name to be sent in the User-Agent header of requests or
null for noneprotected JsonHttpClient(HttpTransport transport, JsonHttpRequestInitializer jsonHttpRequestInitializer, HttpRequestInitializer httpRequestInitializer, JsonFactory jsonFactory, JsonObjectParser jsonObjectParser, String baseUrl, String applicationName)
JsonHttpClient.transport - The transport to use for requestsjsonHttpRequestInitializer - The initializer to use when creating an
JsonHttpRequest or null for nonehttpRequestInitializer - The initializer to use when creating an HttpRequest or
null for nonejsonFactory - A factory for creating JSON parsers and serializersbaseUrl - The base URL of the service. Must end with a "/"applicationName - The application name to be sent in the User-Agent header of requests or
null for noneprotected JsonHttpClient(HttpTransport transport, JsonHttpRequestInitializer jsonHttpRequestInitializer, HttpRequestInitializer httpRequestInitializer, JsonFactory jsonFactory, JsonObjectParser jsonObjectParser, String rootUrl, String servicePath, String applicationName)
JsonHttpClient.transport - The transport to use for requestsjsonHttpRequestInitializer - The initializer to use when creating an
JsonHttpRequest or null for nonehttpRequestInitializer - The initializer to use when creating an HttpRequest or
null for nonejsonFactory - A factory for creating JSON parsers and serializersjsonObjectParser - JSON parser to use or null if unused. null won't be
accepted from 1.11 on.rootUrl - The root URL of the serviceservicePath - The service path of the service. It is allowed to be an empty string
"" or a forward slash "/", if it is a forward slash then it is treated
as an empty stringapplicationName - The application name to be sent in the User-Agent header of requests or
null for noneprotected final boolean isBaseUrlUsed()
servicePath and rootUrl.public final String getBaseUrl()
"https://www.googleapis.com/tasks/v1/"
. Must be URL-encoded and must end with a "/". This is determined when the library is generated
and normally should not be changed.public final String getRootUrl()
https://www.googleapis.com/. Must be
URL-encoded and must end with a "/".public final String getServicePath()
"tasks/v1/". Must be URL-encoded
and must end with a "/" and not begin with a "/". It is allowed to be an empty string
"" or a forward slash "/", if it is a forward slash then it is treated as an
empty stringpublic final String getApplicationName()
null for none.public final JsonFactory getJsonFactory()
public final HttpRequestFactory getRequestFactory()
public final JsonHttpRequestInitializer getJsonHttpRequestInitializer()
null for none.public final JsonHttpParser getJsonHttpParser()
protected JsonHttpParser createParser()
JsonHttpParser
implementations are required.public final JsonObjectParser getJsonObjectParser()
protected JsonHttpContent createSerializer(Object body)
JsonHttpContent implementations are required.body - A POJO that can be serialized into JSONprotected void initialize(JsonHttpRequest jsonHttpRequest) throws IOException
JsonHttpRequest using a JsonHttpRequestInitializer. Subclasses
may override if specific behavior is required.
Must be called before the JSON HTTP request is executed, preferably right after the request is instantiated. Sample usage:
public class Get extends JsonHttpRequest {
...
}
public Get get(String userId) throws IOException {
Get result = new Get(userId);
initialize(result);
return result;
}
jsonHttpRequest - JSON HTTP Request typeIOExceptionprotected HttpRequest buildHttpRequest(HttpMethod method, GenericUrl url, Object body) throws IOException
HttpRequest suitable for use against this service.
Subclasses may override if specific behavior is required, for example if a sequence of requests
need to be built instead of a single request then subclasses should throw an
UnsupportedOperationException. Subclasses which override this method can make use of
HttpRequest.addParser(com.google.api.client.http.HttpParser), HttpRequest.setContent(com.google.api.client.http.HttpContent) and
HttpRequest.setEnableGZipContent(boolean).
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for noneHttpRequestIOExceptionprotected HttpResponse executeUnparsed(HttpMethod method, GenericUrl url, Object body) throws IOException
HttpRequest. Subclasses may override if specific behavior is
required, for example if a sequence of requests need to be built instead of a single request.
Callers are responsible for disconnecting the HTTP response by calling
HttpResponse.disconnect(). Example usage:
HttpResponse response = client.executeUnparsed(method, url, body);
try {
// process response..
} finally {
response.disconnect();
}
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for noneHttpResponse typeIOException - if the request failsprotected HttpResponse executeUnparsed(HttpRequest request) throws IOException
HttpRequest. Subclasses may override if specific behavior is
required, for example if a custom error is required to be thrown.
Callers are responsible for disconnecting the HTTP response by calling
HttpResponse.disconnect(). Example usage:
HttpResponse response = client.executeUnparsed(request);
try {
// process response..
} finally {
response.disconnect();
}
request - HTTP RequestHttpResponse typeIOException - if the request failsprotected InputStream executeAsInputStream(HttpMethod method, GenericUrl url, Object body) throws IOException
HttpRequest and then returns the content input stream of
HttpResponse. Subclasses may override if specific behavior is required.
Callers are responsible for closing the input stream after it is processed. Example usage:
InputStream is = client.executeAsInputStream();
try {
// Process input stream..
} finally {
is.close();
}
method - HTTP Method typeurl - The complete URL of the service where requests should be sentbody - A POJO that can be serialized into JSON or null for noneIOException - if the request failsCopyright © 2011-2012 Google. All Rights Reserved.