Class GenericResponse
-
- All Implemented Interfaces:
-
khttp.responses.Response
public final class GenericResponse implements Response
-
-
Field Summary
Fields Modifier and Type Field Description private final List<Response>historyprivate final HttpURLConnectionconnectionprivate final IntegerstatusCodeprivate final Map<String, String>headersprivate final InputStreamrawprivate final ByteArraycontentprivate final Stringtextprivate final JSONObjectjsonObjectprivate final JSONArrayjsonArrayprivate final CookieJarcookiesprivate final Stringurlprivate Charsetencodingprivate final List<Function2<GenericResponse, HttpURLConnection, Unit>>initializersprivate final Requestrequest
-
Method Summary
Modifier and Type Method Description List<Response>getHistory()A list of KHttpResponse objects from the history of the request. HttpURLConnectiongetConnection()The connection used for the request. IntegergetStatusCode()The status code from the request. Map<String, String>getHeaders()The headers from the request. InputStreamgetRaw()The raw response from the request. ByteArraygetContent()The response as a ByteArray. StringgetText()The response as a String. JSONObjectgetJsonObject()The response as a JSON object. JSONArraygetJsonArray()The response as a JSON array. CookieJargetCookies()The cookies from the request. StringgetUrl()The URL that this request ended up going to. CharsetgetEncoding()The encoding in which to decode text. UnitsetEncoding(Charset encoding)The encoding in which to decode text. final List<Function2<GenericResponse, HttpURLConnection, Unit>>getInitializers()RequestgetRequest()The request that generated this response. Iterator<ByteArray>contentIterator(Integer chunkSize)Gets an Iterator that provides ByteArrays of chunkSize for the content. Iterator<ByteArray>lineIterator(Integer chunkSize, ByteArray delimiter)Gets an Iterator that provides ByteArrays of lines separated by delimiter. StringtoString()-
-
Method Detail
-
getHistory
List<Response> getHistory()
A list of KHttpResponse objects from the history of the request. Any redirect responses will end up here. The list is sorted from the oldest to the most recent request.
-
getConnection
HttpURLConnection getConnection()
The connection used for the request.
-
getStatusCode
Integer getStatusCode()
The status code from the request.
-
getHeaders
Map<String, String> getHeaders()
The headers from the request.
-
getRaw
InputStream getRaw()
The raw response from the request.
-
getContent
ByteArray getContent()
The response as a ByteArray.
-
getJsonObject
JSONObject getJsonObject()
The response as a JSON object.
-
getJsonArray
JSONArray getJsonArray()
The response as a JSON array.
-
getCookies
CookieJar getCookies()
The cookies from the request.
-
getEncoding
Charset getEncoding()
The encoding in which to decode text. If not specified, uses the Content-Type header. If there is no such header, uses UTF-8.
-
setEncoding
Unit setEncoding(Charset encoding)
The encoding in which to decode text. If not specified, uses the Content-Type header. If there is no such header, uses UTF-8.
-
getInitializers
final List<Function2<GenericResponse, HttpURLConnection, Unit>> getInitializers()
-
getRequest
Request getRequest()
The request that generated this response.
-
contentIterator
Iterator<ByteArray> contentIterator(Integer chunkSize)
-
lineIterator
Iterator<ByteArray> lineIterator(Integer chunkSize, ByteArray delimiter)
Gets an Iterator that provides ByteArrays of lines separated by delimiter.
If delimiter is not specified, the delimiter will be
\r?\n.chunkSize sets the size of chunks used by contentIterator internally when scanning for lines.
This method converts lines into Strings and back to ByteArrays using encoding.
-
-
-
-