public static interface Connection.Response extends Connection.Base<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
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.
|
Connection.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.
|
addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url
int statusCode()
java.lang.String statusMessage()
java.lang.String charset()
Connection.Response charset(java.lang.String charset)
charset
- to decode body asjava.lang.String contentType()
Document parse() throws java.io.IOException
bufferUp()
first.java.io.IOException
- on errorjava.lang.String body()
byte[] bodyAsBytes()
Connection.Response bufferUp()
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 body()
or bodyAsBytes()
has the same effect.UncheckedIOException
- if an IO exception occurs during buffering.java.io.BufferedInputStream bodyStream()
This method is useful for writing large responses to disk, without buffering them completely into memory first.