Package discord4j.rest.http.client
Class ClientResponse
java.lang.Object
discord4j.rest.http.client.ClientResponse
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 use bodyToMono(Void.class) if the response is empty.
-
Method Summary
Modifier and TypeMethodDescription<T> Mono<T>bodyToMono(Class<T> responseType) Read the response body and extract it to a single object according to theresponseTypegiven.Create aClientExceptionbased on the contents of this response.getBody()Return the underlyingHttpClientResponsefrom where you can access the response headers, status and context.skipBody()Consume and release the response body then return and emptyMono.toString()
-
Method Details
-
getHttpResponse
Return the underlyingHttpClientResponsefrom where you can access the response headers, status and context.- Returns:
- this response
HttpClientResponse
-
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
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
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
Consume and release the response body then return and emptyMono.- Returns:
- an empty
Monoindicating response body consumption and release
-
toString
-