if the content type is not initially known, the request URL may provide a hint based on the extension of the filename, if present.
the request parameter is ignored if the status is not 200-OK.
the content type received from the webserver, if any.
response headers received from the webserver; only the Content-Length is of interest.
the input stream from the socket connected to the webserver.
In the unbuffered state, this throws an illegal state exception.
In the unbuffered state, this throws an illegal state exception.
The actual content length is only known once the response body has been buffered.
Therefore, use toBufferedBody.asBytes
instead.
In the unbuffered state, this throws an illegal state exception.
In the unbuffered state, this throws an illegal state exception.
The actual content length is only known once the response body has been buffered.
Therefore, use toBufferedBody.asString
instead.
Closes the input stream that provides the data for this response.
Closes the input stream that provides the data for this response. If the implementation buffers the body, the input stream will have been closed automatically.
In the unbuffered state, this throws an illegal state exception.
In the unbuffered state, this throws an illegal state exception.
The actual content length is only known once the response body has been buffered.
Therefore, use toBufferedBody.contentLength
instead.
Gets the content type and encoding of the response.
Gets the content type and encoding of the response. In the unbuffered state, this may not have been supplied by the HTTP server so may not yet be known, in which case the default is "application/octet-stream".
Gets the HTTP response input stream.
Gets the HTTP response input stream. If you read from this stream, it would be unwise later to buffer
the body using toBufferedBody
, because only the remainder would get buffered. Also, once a buffered
body has been obtained, this method must not be used (an exception will be thrown if it is attempted).
the proxied input stream
Tests whether the implementation has buffered the whole response body.
Tests whether the implementation has buffered the whole response body. If this returns false, toBufferedBody
provides an easy route to accumulate the entire body in a buffer.
Tests whether this response body can be represented as text, or whether the data is binary.
Tests whether this response body can be represented as text, or whether the data is binary.
Tests whether the content has been buffered yet.
Tests whether the content has been buffered yet.
Gets the body as a string split into lines of text, if possible.
Gets the body as a string split into lines of text, if possible. If the data is binary, this method always returns an empty iterator.
If the content is textual, this method will throw an illegal state exception if toBufferedBody
has already
been used.
(Changed in version 2.9.0) The behavior of scanRight
has changed. The previous behavior can be reproduced with scanRight.reverse.
Gets the response body in a byte buffer.
Gets the response body in a byte buffer. This consumes the data from the input stream, which cannot subsequently be used here therefore. Any data that has already been consumed will not be included in the resulting buffer.
the response data stored in a buffer
Gets the response body as a string for diagnostic purposes.
Gets the response body as a string for diagnostic purposes.
Gets the response body in a string buffer.
Gets the response body in a string buffer. This consumes the data from the input stream, which cannot subsequently be used here therefore. Any data that has already been consumed will not be included in the resulting buffer.
the response data stored in a buffer
Gets a proxy for the HTTP response input stream in which each line is transformed using a specified function.
Gets a proxy for the HTTP response input stream in which each line is transformed using a specified function. Be careful about the potential impact on performance of your filter on line-by-line processing; you may need to measure this approach in comparison with other alternatives.
the function to be applied to each line.
the proxied input stream
(Changed in version 2.9.0) transpose
throws an IllegalArgumentException
if collections are not uniformly sized.
Provides a body implementation that holds the HTTP server's input stream as obtained from the HttpURLConnection. This provides access to the underlying InputStream, with or without a filtering function to transform the text, Also, is can also easily be iterated over as a sequence of strings.
Alternatively, it can be converted into a uk.co.bigbeeconsultants.http.response.ByteBufferResponseBody (which is simpler to use) if the whole body is required as a block of bytes or a string.
It is not safe to share instances between threads.
The socket input stream *must* be closed by the calling code. This happens automatically when all the data has been consumed from the socket, but if it is necessary to give up immediately or part-way through, it is necessary to ensure that
inputStream.close()
is invoked (usually in afinally
block).Conversion
toBufferedBody
is another way to ensure the input stream gets closed.