public class ByteResponse extends Object
| Constructor and Description |
|---|
ByteResponse(RawResponse r) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBody() |
Cookies |
getCookies()
return a cookie collection parse from the set-cookie header
|
Headers |
getHeaders() |
Optional<UnirestParsingException> |
getParsingError()
If the transformation to the body failed by an exception it will be kept here
|
protected String |
getRawBody() |
int |
getStatus() |
String |
getStatusText() |
<E> HttpResponse<T> |
ifFailure(Class<? extends E> errorClass,
Consumer<HttpResponse<E>> consumer)
If the response was NOT a 200-series response or a mapping exception happened.
|
HttpResponse<T> |
ifFailure(Consumer<HttpResponse<T>> consumer)
If the response was NOT a 200-series response or a mapping exception happened.
|
HttpResponse<T> |
ifSuccess(Consumer<HttpResponse<T>> consumer)
If the response was a 200-series response.
|
boolean |
isSuccess() |
<V> HttpResponse<V> |
map(Function<T,V> func)
Map the Response into another response with a different body
|
<V> V |
mapBody(Function<T,V> func)
Map the body into another type
|
<E> E |
mapError(Class<? extends E> errorClass)
Map the body into a error class if the response was NOT a 200-series response or a mapping exception happened.
|
protected void |
setParsingException(String originalBody,
RuntimeException e) |
public ByteResponse(RawResponse r)
public byte[] getBody()
getBody in interface HttpResponse<byte[]>protected String getRawBody()
public int getStatus()
getStatus in interface HttpResponse<T>public String getStatusText()
getStatusText in interface HttpResponse<T>public Headers getHeaders()
getHeaders in interface HttpResponse<T>getHeaders().getFirst("Location") and not getHeaders().getFirst("location") to get first header "Location"public Optional<UnirestParsingException> getParsingError()
HttpResponsegetParsingError in interface HttpResponse<T>public <V> V mapBody(Function<T,V> func)
HttpResponsemapBody in interface HttpResponse<T>V - The return type of the functionfunc - a function to transform a body type to something else.public <V> HttpResponse<V> map(Function<T,V> func)
HttpResponsemap in interface HttpResponse<T>V - The return type of the functionfunc - a function to transform a body type to something else.protected void setParsingException(String originalBody, RuntimeException e)
public boolean isSuccess()
isSuccess in interface HttpResponse<T>public HttpResponse<T> ifSuccess(Consumer<HttpResponse<T>> consumer)
HttpResponseifSuccess in interface HttpResponse<T>consumer - a function to consume a HttpResponsepublic HttpResponse<T> ifFailure(Consumer<HttpResponse<T>> consumer)
HttpResponseifFailure in interface HttpResponse<T>consumer - a function to consume a HttpResponsepublic <E> E mapError(Class<? extends E> errorClass)
HttpResponsemapError in interface HttpResponse<T>E - the response typeerrorClass - the class for the errorpublic <E> HttpResponse<T> ifFailure(Class<? extends E> errorClass, Consumer<HttpResponse<E>> consumer)
HttpResponseifFailure in interface HttpResponse<T>E - the type of error class to map the bodyerrorClass - the class of the error type to map toconsumer - a function to consume a HttpResponsepublic Cookies getCookies()
HttpResponsegetCookies in interface HttpResponse<T>Copyright © 2021. All rights reserved.