public static class HttpConnection.Response extends java.lang.Object implements Connection.Response
Modifier and Type | Method and Description |
---|---|
java.lang.String |
body()
Get the body of the response as a plain string.
|
byte[] |
bodyAsBytes()
Get the body of the response as an array of bytes.
|
java.io.BufferedInputStream |
bodyStream()
Get the body of the response as a (buffered) InputStream.
|
Connection.Response |
bufferUp()
Read the body of the response into a local buffer, so that
Connection.Response.parse() may be called repeatedly on the
same connection response (otherwise, once the response is read, its InputStream will have been drained and
may not be re-read). |
java.lang.String |
charset()
Get the character set name of the response, derived from the content-type header.
|
HttpConnection.Response |
charset(java.lang.String charset)
Set / override the response character set.
|
java.lang.String |
contentType()
Get the response content type (e.g.
|
Document |
parse()
Read and parse the body of the response as a Document.
|
int |
statusCode()
Get the status code of the response.
|
java.lang.String |
statusMessage()
Get the status message of the response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url
public int statusCode()
Connection.Response
statusCode
in interface Connection.Response
public java.lang.String statusMessage()
Connection.Response
statusMessage
in interface Connection.Response
public java.lang.String charset()
Connection.Response
charset
in interface Connection.Response
public HttpConnection.Response charset(java.lang.String charset)
Connection.Response
charset
in interface Connection.Response
charset
- to decode body aspublic java.lang.String contentType()
Connection.Response
contentType
in interface Connection.Response
public Document parse() throws java.io.IOException
Connection.Response
Connection.Response.bufferUp()
first.parse
in interface Connection.Response
java.io.IOException
- on errorpublic java.lang.String body()
Connection.Response
body
in interface Connection.Response
public byte[] bodyAsBytes()
Connection.Response
bodyAsBytes
in interface Connection.Response
public Connection.Response bufferUp()
Connection.Response
Connection.Response.parse()
may be called repeatedly on the
same connection response (otherwise, once the response is read, its InputStream will have been drained and
may not be re-read). Calling Connection.Response.body()
or Connection.Response.bodyAsBytes()
has the same effect.bufferUp
in interface Connection.Response
public java.io.BufferedInputStream bodyStream()
Connection.Response
This method is useful for writing large responses to disk, without buffering them completely into memory first.
bodyStream
in interface Connection.Response