Package com.jcabi.http.request
Class DefaultResponse
- java.lang.Object
-
- com.jcabi.http.request.DefaultResponse
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Response>
Tas(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'sUTF-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.String
toString()
-
-
-
Constructor Detail
-
DefaultResponse
public DefaultResponse(Request request, int status, String reason, com.jcabi.immutable.Array<Map.Entry<String,String>> headers, byte[] body)
Public ctor.- Parameters:
request
- The requeststatus
- HTTP statusreason
- HTTP reason phraseheaders
- HTTP headersbody
- Body of HTTP response
-
-
Method Detail
-
back
public Request back()
Description copied from interface:Response
Get back to the request it's related to.
-
status
public int status()
Description copied from interface:Response
Get status of the response as a positive integer number.
-
reason
public String reason()
Description copied from interface:Response
Get status line reason phrase.
-
headers
public Map<String,List<String>> headers()
Description copied from interface:Response
Get a collection of all headers.
-
body
public String body()
Description copied from interface:Response
Get body as a string, assuming it'sUTF-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, useResponse.binary()
instead.
-
binary
public byte[] binary()
Description copied from interface:Response
Raw body as a an array of bytes.
-
as
public <T extends Response> T as(Class<T> type)
Description copied from interface:Response
Convert it to another type, by encapsulation.
-
-