public class BinaryResponse extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
BinaryResponse(RawResponse response) |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
getBody() |
Headers |
getHeaders() |
Optional<UnirestParsingException> |
getParsingError()
If the transformation to the body failed by an exception it will be kept here
|
InputStream |
getRawBody()
This method is a lie.
|
int |
getStatus() |
String |
getStatusText() |
HttpResponse<T> |
ifFailure(java.util.function.Consumer<HttpResponse<T>> consumer)
If the response was NOT a 200-series response or a mapping exception happened.
|
HttpResponse<T> |
ifSuccess(java.util.function.Consumer<HttpResponse<T>> consumer)
If the response was a 200-series response.
|
boolean |
isSuccess() |
<V> V |
mapBody(java.util.function.Function<T,V> func) |
<V> V |
mapRawBody(java.util.function.Function<InputStream,V> func)
This method is a lie.
|
protected void |
setParsingException(String originalBody,
RuntimeException e) |
protected BinaryResponse(RawResponse response)
public InputStream getRawBody()
HttpResponsegetRawBody in interface HttpResponse<InputStream>public InputStream getBody()
getBody in interface HttpResponse<InputStream>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(java.util.function.Function<T,V> func)
mapBody in interface HttpResponse<T>V - The return type of the functionfunc - a function to transform a body type to something else.public <V> V mapRawBody(java.util.function.Function<InputStream,V> func)
HttpResponsemapRawBody in interface HttpResponse<T>V - the return typefunc - a function to map a inputstream to a new bodyprotected void setParsingException(String originalBody, RuntimeException e)
public HttpResponse<T> ifSuccess(java.util.function.Consumer<HttpResponse<T>> consumer)
HttpResponseifSuccess in interface HttpResponse<T>consumer - a function to consume a HttpResponsepublic HttpResponse<T> ifFailure(java.util.function.Consumer<HttpResponse<T>> consumer)
HttpResponseifFailure in interface HttpResponse<T>consumer - a function to consume a HttpResponsepublic boolean isSuccess()
isSuccess in interface HttpResponse<T>Copyright © 2019. All rights reserved.