|
||||||||||
| 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.
| Field Summary | |
|---|---|
String |
contentEncoding
Content encoding or null. |
String |
contentType
Content type or null for none. |
boolean |
disableContentLogging
Whether to disable response content logging during getContent() (unless
Level.ALL is loggable which forces all logging). |
HttpHeaders |
headers
HTTP headers. |
boolean |
isSuccessStatusCode
Whether received a successful status code >= 200 && < 300. |
HttpRequest |
request
HTTP request. |
int |
statusCode
Status code. |
String |
statusMessage
Status message or null. |
HttpTransport |
transport
HTTP transport. |
| Method Summary | ||
|---|---|---|
void |
disconnect()
Disconnect using LowLevelHttpResponse.disconnect(). |
|
InputStream |
getContent()
Returns the content of the HTTP response. |
|
HttpParser |
getParser()
Returns the HTTP response content parser to use for the content type of this HTTP response or null for none. |
|
void |
ignore()
Closes the the content of the HTTP response from getContent(), ignoring any content. |
|
static boolean |
isSuccessStatusCode(int statusCode)
Returns whether the given HTTP response status code is a success code >= 200 and < 300. |
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final String contentEncoding
null.
public final String contentType
null for none.
public final HttpHeaders headers
If a header name is used for multiple headers, only the last one is retained. The value is
initialized to HttpRequest.responseHeaders before being parsed from the actual HTTP
response headers.
public final boolean isSuccessStatusCode
>= 200 && < 300.
public final int statusCode
public final String statusMessage
null.
public final HttpTransport transport
public final HttpRequest request
public boolean disableContentLogging
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.
| Method Detail |
|---|
public InputStream getContent()
throws IOException
The result is cached, so subsequent calls will be fast.
null for none
IOException - I/O exception
public void ignore()
throws IOException
getContent(), ignoring any content.
IOException
public void disconnect()
throws IOException
LowLevelHttpResponse.disconnect().
IOExceptionpublic 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 response
public 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 exceptionpublic static boolean isSuccessStatusCode(int statusCode)
>= 200 and < 300.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||