Package discord4j.rest.http.client
Class ClientResponse
- java.lang.Object
-
- discord4j.rest.http.client.ClientResponse
-
public class ClientResponse extends Object
An HTTP response encapsulating status, headers and accessors to the response body for consumption.Make sure you call
bodyToMono(Class),skipBody()or similar and actually consume the response body. It is possible to usebodyToMono(Void.class)if the response is empty.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Mono<T>bodyToMono(Class<T> responseType)Read the response body and extract it to a single object according to theresponseTypegiven.Mono<ClientException>createException()Create aClientExceptionbased on the contents of this response.Mono<ByteBuf>getBody()HttpClientResponsegetHttpResponse()Return the underlyingHttpClientResponsefrom where you can access the response headers, status and context.Mono<Void>skipBody()Consume and release the response body then return and emptyMono.StringtoString()
-
-
-
Method Detail
-
getHttpResponse
public HttpClientResponse getHttpResponse()
Return the underlyingHttpClientResponsefrom where you can access the response headers, status and context.- Returns:
- this response
HttpClientResponse
-
getBody
public Mono<ByteBuf> getBody()
Return the body of this response as aMonoofByteBuf. If thisMonois cancelled, then it will not be possible to consume the body again.- Returns:
- the response body contents
-
bodyToMono
public <T> Mono<T> bodyToMono(Class<T> responseType)
Read the response body and extract it to a single object according to theresponseTypegiven. If the response has an HTTP error (status codes 4xx and 5xx) the produced object will be aClientException.
-
createException
public Mono<ClientException> createException()
Create aClientExceptionbased on the contents of this response. This method will attempt to extract anErrorResponsefrom the body if possible.- Returns:
- a
MonoofClientExceptionfrom this response
-
skipBody
public Mono<Void> skipBody()
Consume and release the response body then return and emptyMono.- Returns:
- an empty
Monoindicating response body consumption and release
-
-