@Immutable public interface Response
Request.fetch()
.
You can get this response from one of implementations of Request
:
Response response = new JdkRequest("https://www.google.com") .header("Accept", "text/html") .fetch();
Instances of this interface are immutable and thread-safe.
JdkRequest
Modifier and Type | Method and Description |
---|---|
<T> T |
as(Class<T> type)
Convert it to another type, by encapsulation.
|
Request |
back()
Get back to the request it's related to.
|
byte[] |
binary()
Raw body as a an array of bytes.
|
String |
body()
Get body as a string, assuming it's
UTF-8 (if there is something
else that can't be translated into a UTF-8 string a runtime exception
will be thrown). |
Map<String,List<String>> |
headers()
Get a collection of all headers.
|
String |
reason()
Get status line reason phrase.
|
int |
status()
Get status of the response as a positive integer number.
|
@NotNull(message="request is never NULL") Request back()
int status()
@NotNull(message="reason phrase is never NULL") String reason()
@NotNull(message="map of headers is never NULL") Map<String,List<String>> headers()
@NotNull(message="response body is never NULL") String body()
UTF-8
(if there is something
else that can't be translated into a UTF-8 string a runtime exception
will be thrown).
DISCLAIMER:
The only encoding supported here is UTF-8. If the body of response
contains any chars that can't be used and should be replaced with
a "replacement character", a RuntimeException
will be thrown. If
you need to use some other encodings, use
binary()
instead.
@NotNull(message="response data is never NULL") byte[] binary()
<T> T as(Class<T> type)
T
- Type to usetype
- Type to useCopyright © 2012–2014 jcabi.com. All rights reserved.