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
ConstructorsConstructorDescriptionHttpResponseAdapter(HttpResponse<byte[]> httpResponse, @Nullable Argument<O> bodyType, ConversionService conversionService, MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry) -
Method Summary
Modifier and TypeMethodDescriptionintcode()AMutableConvertibleValuesof 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, waitMethods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttributeMethods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocaleMethods inherited from interface io.micronaut.http.HttpResponse
body, getCookie, getCookies, header, setAttribute, status, toMutableResponseMethods 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:HttpMessageReturn the body as the given type.- Type Parameters:
T- The generic type- Parameters:
type- The type of the body- Returns:
- An
Optionalof the type orOptional.empty()if the body cannot be returned as the given type
-
getStatus
- Specified by:
getStatusin 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:
codein interfaceHttpResponse<B>- Returns:
- The response status code
-
reason
- Specified by:
reasonin interfaceHttpResponse<B>- Returns:
- The HTTP status reason phrase
-
getHeaders
- Specified by:
getHeadersin interfaceHttpMessage<B>- Returns:
- The
HttpHeadersobject
-
getAttributes
Description copied from interface:HttpMessageA
MutableConvertibleValuesof 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:
getAttributesin interfaceAttributeHolder- Specified by:
getAttributesin interfaceHttpMessage<B>- Specified by:
getAttributesin interfaceMutableAttributeHolder- Returns:
- The attributes of the message
-