|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.HttpResponse
public final class HttpResponse
HTTP response.
Implementation is not thread-safe.
Method Summary | ||
---|---|---|
void |
disconnect()
Disconnect using LowLevelHttpResponse.disconnect() . |
|
InputStream |
getContent()
Returns the content of the HTTP response. |
|
String |
getContentEncoding()
Returns the content encoding or null for none. |
|
int |
getContentLoggingLimit()
Returns the limit to the content size that will be logged during getContent() . |
|
String |
getContentType()
Returns the content type or null for none. |
|
boolean |
getDisableContentLogging()
Deprecated. (scheduled to be removed in 1.8) Use getContentLoggingLimit() |
|
HttpHeaders |
getHeaders()
Returns the HTTP response headers. |
|
HttpParser |
getParser()
Returns the HTTP response content parser to use for the content type of this HTTP response or null for none. |
|
HttpRequest |
getRequest()
Returns the HTTP request. |
|
int |
getStatusCode()
Returns the HTTP status code or 0 for none. |
|
String |
getStatusMessage()
Returns the HTTP status message or null for none. |
|
HttpTransport |
getTransport()
Returns the HTTP transport. |
|
void |
ignore()
Closes the the content of the HTTP response from getContent() , ignoring any content. |
|
boolean |
isSuccessStatusCode()
Returns whether received a successful HTTP status code >= 200 && < 300 (see
getStatusCode() ). |
|
|
parseAs(Class<T> dataClass)
Parses the content of the HTTP response from getContent() and reads it into a data
class of key/value pairs using the parser returned by getParser() . |
|
String |
parseAsString()
Parses the content of the HTTP response from getContent() and reads it into a string. |
|
HttpResponse |
setContentLoggingLimit(int contentLoggingLimit)
Set the limit to the content size that will be logged during getContent() . |
|
HttpResponse |
setDisableContentLogging(boolean disableContentLogging)
Deprecated. (scheduled to be removed in 1.8) Use setContentLoggingLimit(int) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
@Deprecated public boolean getDisableContentLogging()
getContentLoggingLimit()
getContent()
(unless
Level.ALL
is loggable which forces all logging).
public int getContentLoggingLimit()
getContent()
.
If the content size is greater than this limit then it will not be logged.
Can be set to 0
to disable content logging. This is useful for example if content has
sensitive data such as authentication information.
Defaults to 100000 (100KB)
.
@Deprecated public HttpResponse setDisableContentLogging(boolean disableContentLogging)
setContentLoggingLimit(int)
getContent()
(unless
Level.ALL
is loggable which forces all logging).
Useful for example if content has sensitive data such as an authentication token. Defaults to
false
.
public HttpResponse setContentLoggingLimit(int contentLoggingLimit)
getContent()
.
If the content size is greater than this limit then it will not be logged.
Can be set to 0
to disable content logging. This is useful for example if content has
sensitive data such as authentication information.
Defaults to 100000 (100KB)
.
public String getContentEncoding()
null
for none.
public String getContentType()
null
for none.
public HttpHeaders getHeaders()
public boolean isSuccessStatusCode()
>= 200 && < 300
(see
getStatusCode()
).
public int getStatusCode()
0
for none.
public String getStatusMessage()
null
for none.
public HttpTransport getTransport()
public HttpRequest getRequest()
public InputStream getContent() throws IOException
The result is cached, so subsequent calls will be fast.
null
for none
IOException
- I/O exceptionpublic void ignore() throws IOException
getContent()
, ignoring any content.
IOException
public void disconnect() throws IOException
LowLevelHttpResponse.disconnect()
.
IOException
public HttpParser getParser()
null
for none.
public <T> T parseAs(Class<T> dataClass) throws IOException
getContent()
and reads it into a data
class of key/value pairs using the parser returned by getParser()
.
null
for no content
IOException
- I/O exception
IllegalArgumentException
- if no parser is defined for the given content type or if there
is no content type defined in the HTTP responsepublic String parseAsString() throws IOException
getContent()
and reads it into a string.
Since this method returns ""
for no content, a simpler check for no content is to check
if getContent()
is null
.
""
for no content
IOException
- I/O exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |