|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gdata.client.http.HttpGDataRequest
public class HttpGDataRequest
The HttpGDataRequest class provides a basic implementation of the
GDataRequest interface over HTTP.
Service.GDataRequest| Nested Class Summary | |
|---|---|
static class |
HttpGDataRequest.Factory
The HttpGDataRequest.Factory class is a factory class for constructing new HttpGDataRequest instances. |
| Nested classes/interfaces inherited from interface com.google.gdata.client.Service.GDataRequest |
|---|
Service.GDataRequest.RequestType |
| Field Summary | |
|---|---|
protected HttpUrlConnectionSource |
connectionSource
Source of HttpURLConnection instances. |
protected int |
connectTimeout
The connection timeout for this request. |
protected boolean |
executed
Indicates whether request execution has taken place. |
protected boolean |
expectsInput
True if the request type expects input from the client. |
protected boolean |
hasOutput
True if the request type returns output to the client. |
protected java.net.HttpURLConnection |
httpConn
Underlying HTTP connection to the GData service. |
protected ContentType |
inputType
Contains the content type of the request data |
static java.lang.String |
METHOD_OVERRIDE_HEADER
Deprecated. Use GDataProtocol.Header#METHOD_OVERRIDE instead |
static java.lang.String |
METHOD_OVERRIDE_PROPERTY
If this system property is set to true, the GData HTTP
client library will use POST to send data to the associated GData service
and will specify the actual method using the METHOD_OVERRIDE_HEADER
HTTP header. |
protected int |
readTimeout
The read timeout for this request. |
protected java.net.URL |
requestUrl
The request URL provided by the client. |
protected Service.GDataRequest.RequestType |
type
The GData request type. |
| Constructor Summary | |
|---|---|
protected |
HttpGDataRequest()
Protected default constructor for testing. |
protected |
HttpGDataRequest(Service.GDataRequest.RequestType type,
java.net.URL requestUrl,
ContentType inputType,
HttpAuthToken authToken,
java.util.Map<java.lang.String,java.lang.String> headerMap,
java.util.Map<java.lang.String,java.lang.String> privateHeaderMap,
HttpUrlConnectionSource connectionSource)
Constructs a new HttpGDataRequest instance of the specified RequestType, targeting the specified URL. |
| Method Summary | |
|---|---|
protected void |
checkResponse()
Called after a request is executed to process the response and generate an appropriate exception (on failure). |
void |
end()
Ends all processing associated with this request and releases any transient resources (such as open data streams) required for execution. |
void |
execute()
Executes the GData service request. |
java.net.HttpURLConnection |
getConnection()
Returns the URLConnection instance that represents the underlying connection to the GData service that will be used by this request. |
ParseSource |
getParseSource()
Returns a parse source that can be used to read response data from the GData service. |
protected java.net.HttpURLConnection |
getRequestConnection(java.net.URL requestUrl)
Obtains a connection to the GData service. |
ContentType |
getRequestContentType()
Returns the ContentType of the data that will be written to the
service by this request or null if no data is written to the
server by the request. |
java.io.OutputStream |
getRequestStream()
Returns a stream that can be used to write request data to the GData service. |
java.net.URL |
getRequestUrl()
Returns the URL that is the target of the GData request |
com.google.gdata.util.common.xml.XmlWriter |
getRequestWriter()
|
ContentType |
getResponseContentType()
Returns the content type of the GData response. |
DateTime |
getResponseDateHeader(java.lang.String headerName)
Returns the value of a header containing a header or null if no
response header of this type exists or it could not be parsed as a valid
date. |
java.lang.String |
getResponseHeader(java.lang.String headerName)
Returns the value of the specified response header name or null
if no response header of this type exists. |
java.io.InputStream |
getResponseStream()
Returns an input stream that can be used to read response data from the GData service. |
protected void |
handleErrorResponse()
Handles an error response received while executing a GData service request. |
void |
setConnectTimeout(int timeout)
Sets the number of milliseconds to wait for a connection to the remote GData service before timing out. |
void |
setEtag(java.lang.String etag)
Sets the entity tag value that will be used to conditionalize the request if not null. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a request header (and logs it, if logging is enabled) |
void |
setIfModifiedSince(DateTime conditionDate)
Sets the If-Modified-Since date precondition to be applied to the request. |
void |
setMethod(java.lang.String method)
|
void |
setPrivateHeader(java.lang.String name,
java.lang.String value)
Sets request header (and log just the name but not the value, if logging is enabled) |
void |
setReadTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the remote GData service before timing out. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String METHOD_OVERRIDE_PROPERTY
true, the GData HTTP
client library will use POST to send data to the associated GData service
and will specify the actual method using the METHOD_OVERRIDE_HEADER
HTTP header. This can be used as a workaround for HTTP proxies or gateways
that do not handle PUT or DELETE HTTP methods properly. If the system
property is false, the regular PUT and DELETE HTTP verbs
will be used.
@Deprecated public static final java.lang.String METHOD_OVERRIDE_HEADER
GDataProtocol.Header#METHOD_OVERRIDE instead
protected final HttpUrlConnectionSource connectionSource
HttpURLConnection instances.
protected java.net.HttpURLConnection httpConn
protected java.net.URL requestUrl
protected Service.GDataRequest.RequestType type
protected boolean executed
true if executed, false otherwise.
protected boolean expectsInput
protected ContentType inputType
protected boolean hasOutput
protected int connectTimeout
protected int readTimeout
| Constructor Detail |
|---|
protected HttpGDataRequest(Service.GDataRequest.RequestType type,
java.net.URL requestUrl,
ContentType inputType,
HttpAuthToken authToken,
java.util.Map<java.lang.String,java.lang.String> headerMap,
java.util.Map<java.lang.String,java.lang.String> privateHeaderMap,
HttpUrlConnectionSource connectionSource)
throws java.io.IOException
type - type of GDataRequest.requestUrl - request target URL.inputType - the content type of request data (or null).headerMap - a set of headers to be included in each requestprivateHeaderMap - a set of headers to be included in each requestconnectionSource - source of HttpURLConnections
java.io.IOException - on error initializating service connection.protected HttpGDataRequest()
| Method Detail |
|---|
public java.net.URL getRequestUrl()
Service.GDataRequestURL that is the target of the GData request
getRequestUrl in interface Service.GDataRequestpublic ContentType getRequestContentType()
Service.GDataRequestContentType of the data that will be written to the
service by this request or null if no data is written to the
server by the request.
getRequestContentType in interface Service.GDataRequest
protected java.net.HttpURLConnection getRequestConnection(java.net.URL requestUrl)
throws java.io.IOException
java.io.IOExceptionpublic void setConnectTimeout(int timeout)
Service.GDataRequest
setConnectTimeout in interface Service.GDataRequesttimeout - the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setConnectTimeout(int)public void setReadTimeout(int timeout)
Service.GDataRequest
setReadTimeout in interface Service.GDataRequesttimeout - the read timeout. A value of zero indicates an infinite
timeout.URLConnection.setReadTimeout(int)public void setIfModifiedSince(DateTime conditionDate)
Service.GDataRequestNotModifiedException will be thrown. The default
value is null, indicating no precondition.
setIfModifiedSince in interface Service.GDataRequestconditionDate - the date that should be used to limit the operation
on the target resource. The operation will only be performed if
the resource has been modified later than the specified date.public void setEtag(java.lang.String etag)
Service.GDataRequestnull. For a query requests, the tag will cause the target
resource to be returned if the resource entity tag does not match
the specified value (i.e. if the resource has not changed). For update or
delete request types, the entity tag value is used to indicate that the
requested operation should occur only if the specified etag value does
match the specified value (i.e. if the resource has changed). A
request entity tag value may not be associated with other request types.
setEtag in interface Service.GDataRequest
public java.io.OutputStream getRequestStream()
throws java.io.IOException
Service.GDataRequest
getRequestStream in interface Service.GDataRequestjava.io.IOException - error obtaining the request output stream.
public com.google.gdata.util.common.xml.XmlWriter getRequestWriter()
throws java.io.IOException
java.io.IOException
public void setMethod(java.lang.String method)
throws java.net.ProtocolException
java.net.ProtocolException
public void setHeader(java.lang.String name,
java.lang.String value)
Service.GDataRequest
setHeader in interface Service.GDataRequestname - the header namevalue - the header value
public void setPrivateHeader(java.lang.String name,
java.lang.String value)
Service.GDataRequest
setPrivateHeader in interface Service.GDataRequestname - the header namevalue - the header value
public void execute()
throws java.io.IOException,
ServiceException
Service.GDataRequest
execute in interface Service.GDataRequestjava.io.IOException - error writing to or reading from GData service.
ResourceNotFoundException - invalid request
target resource.
ServiceException - system error executing request.
protected void checkResponse()
throws java.io.IOException,
ServiceException
java.io.IOException
ServiceException
protected void handleErrorResponse()
throws ServiceException,
java.io.IOException
ServiceException or one of its subclasses, depending on
the failure conditions.
ServiceException - exception describing the failure.
java.io.IOException - error reading the error response from the GData
service.public ContentType getResponseContentType()
Service.GDataRequest
getResponseContentType in interface Service.GDataRequestnull if no
response content.public java.lang.String getResponseHeader(java.lang.String headerName)
Service.GDataRequestnull
if no response header of this type exists.
getResponseHeader in interface Service.GDataRequestheaderName - name of header
public DateTime getResponseDateHeader(java.lang.String headerName)
Service.GDataRequestnull if no
response header of this type exists or it could not be parsed as a valid
date.
getResponseDateHeader in interface Service.GDataRequestheaderName - name of header
public java.io.InputStream getResponseStream()
throws java.io.IOException
Service.GDataRequestService.GDataRequest.getParseSource() instead.
The caller is responsible for ensuring that the input stream is properly closed after the response has been read.
getResponseStream in interface Service.GDataRequestjava.io.IOException - error obtaining the response input stream.
public ParseSource getParseSource()
throws java.io.IOException
Service.GDataRequestThe caller is responsible for ensuring that input streams and readers contained in the parse source are properly closed after the response has been read.
getParseSource in interface Service.GDataRequestjava.io.IOException - error obtaining the response data.public java.net.HttpURLConnection getConnection()
public void end()
Service.GDataRequest
end in interface Service.GDataRequest
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||