Interface HttpResponse
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public interface HttpResponse implements AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceHttpResponse.Handler
-
Method Summary
Modifier and Type Method Description abstract IntegerstatusCode()abstract Headersheaders()Optional<String>requestId()Returns the value of the request-idheader, or an empty Optional if there's no such header in the response.abstract InputStreambody()<T extends Any> Tjson(Class<T> clazz)Returns the response body parsed as JSON into an instance of the given class. HttpResponsebuffered()Returns a response equivalent to this response, but whose body returns a new InputStream on each call, so it can be read repeatedly. abstract Unitclose()Overridden from AutoCloseable to not have a checked exception in its signature. -
-
Method Detail
-
statusCode
abstract Integer statusCode()
-
requestId
Optional<String> requestId()
Returns the value of the
request-idheader, or an empty Optional if there's no such header in the response.
-
body
abstract InputStream body()
-
json
<T extends Any> T json(Class<T> clazz)
Returns the response body parsed as JSON into an instance of the given class.
This method consumes the body stream. To also read the body in other ways, call buffered first and call this method on the returned response.
-
buffered
HttpResponse buffered()
Returns a response equivalent to this response, but whose body returns a new InputStream on each call, so it can be read repeatedly.
The first call to the returned response's body fully reads this response's body into memory, so this response should no longer be used directly. Closing the returned response closes this response. Calling buffered on the returned response returns it unchanged.
-
close
abstract Unit close()
Overridden from AutoCloseable to not have a checked exception in its signature.
-
-
-
-