Package io.micronaut.http.client.jdk
Class HttpResponseAdapter<O>
java.lang.Object
io.micronaut.http.client.jdk.HttpResponseAdapter<O>
- Type Parameters:
O
- Body Type
- All Implemented Interfaces:
AttributeHolder
,MutableAttributeHolder
,HttpMessage<O>
,HttpResponse<O>
Adapter from
HttpResponse
to HttpResponse
.- Since:
- 4.0.0
- Author:
- Sergio del Amo
-
Constructor Summary
ConstructorDescriptionHttpResponseAdapter
(HttpResponse<byte[]> httpResponse, @Nullable Argument<O> bodyType, ConversionService conversionService, MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry) -
Method Summary
Modifier and TypeMethodDescriptionint
code()
AMutableConvertibleValues
of the attributes for this HTTP message.getBody()
<T> Optional<T>
Return the body as the given type.reason()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocale
Methods inherited from interface io.micronaut.http.HttpResponse
body, getCookie, getCookies, header, setAttribute, status, toMutableResponse
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
Constructor Details
-
HttpResponseAdapter
public HttpResponseAdapter(HttpResponse<byte[]> httpResponse, @Nullable @Nullable Argument<O> bodyType, ConversionService conversionService, MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry)
-
-
Method Details
-
getBody
- Returns:
- The request body
-
getBody
Description copied from interface:HttpMessage
Return the body as the given type.- Type Parameters:
T
- The generic type- Parameters:
type
- The type of the body- Returns:
- An
Optional
of the type orOptional.empty()
if the body cannot be returned as the given type
-
getStatus
- Specified by:
getStatus
in interfaceHttpResponse<B>
- Returns:
- The current status
To support custom status codes. Use
HttpResponse.code()
instead ofHttpResponse.getStatus()
andHttpStatus.getCode()
andHttpResponse.reason()
instead ofHttpResponse.getStatus()
andHttpStatus.getReason()
-
code
public int code()- Specified by:
code
in interfaceHttpResponse<B>
- Returns:
- The response status code
-
reason
- Specified by:
reason
in interfaceHttpResponse<B>
- Returns:
- The HTTP status reason phrase
-
getHeaders
- Specified by:
getHeaders
in interfaceHttpMessage<B>
- Returns:
- The
HttpHeaders
object
-
getAttributes
Description copied from interface:HttpMessage
A
MutableConvertibleValues
of the attributes for this HTTP message.Attributes are designed for internal data sharing and hence are isolated from headers and parameters which are client supplied
- Specified by:
getAttributes
in interfaceAttributeHolder
- Specified by:
getAttributes
in interfaceHttpMessage<B>
- Specified by:
getAttributes
in interfaceMutableAttributeHolder
- Returns:
- The attributes of the message
-