Package io.micronaut.http
Interface HttpMessage<B>
-
- Type Parameters:
B- The body type
- All Superinterfaces:
io.micronaut.core.attr.AttributeHolder,io.micronaut.core.attr.MutableAttributeHolder
- All Known Subinterfaces:
HttpRequest<B>,HttpResponse<B>,MutableHttpMessage<B>,MutableHttpRequest<B>,MutableHttpResponse<B>,PushCapableHttpRequest<B>
- All Known Implementing Classes:
FullHttpRequest,HttpMessageWrapper,HttpRequestWrapper,HttpResponseWrapper,SimpleHttpRequest
public interface HttpMessage<B> extends io.micronaut.core.attr.MutableAttributeHolderCommon interface for HTTP messages.- Since:
- 1.0
- See Also:
HttpRequest,HttpResponse
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>getAttributes()AMutableConvertibleValuesof the attributes for this HTTP message.java.util.Optional<B>getBody()default <T> java.util.Optional<T>getBody(io.micronaut.core.type.Argument<T> type)Return the body as the given type.default <T> java.util.Optional<T>getBody(java.lang.Class<T> type)Return the body as the given type.default java.nio.charset.CharsetgetCharacterEncoding()default longgetContentLength()default java.util.Optional<MediaType>getContentType()The request or response content type.HttpHeadersgetHeaders()default java.util.Optional<java.util.Locale>getLocale()default HttpMessage<B>setAttribute(java.lang.CharSequence name, java.lang.Object value)
-
-
-
Method Detail
-
getHeaders
@NonNull HttpHeaders getHeaders()
- Returns:
- The
HttpHeadersobject
-
getAttributes
@NonNull io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
A
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 interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder- Returns:
- The attributes of the message
-
getBody
@NonNull java.util.Optional<B> getBody()
- Returns:
- The request body
-
getCharacterEncoding
@NonNull default java.nio.charset.Charset getCharacterEncoding()
- Returns:
- The request character encoding. Defaults to
StandardCharsets.UTF_8
-
setAttribute
@NonNull default HttpMessage<B> setAttribute(@NonNull java.lang.CharSequence name, java.lang.Object value)
- Specified by:
setAttributein interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getBody
@NonNull default <T> java.util.Optional<T> getBody(@NonNull io.micronaut.core.type.Argument<T> type)Return 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
-
getBody
@NonNull default <T> java.util.Optional<T> getBody(@NonNull java.lang.Class<T> type)Return 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
-
getLocale
@NonNull default java.util.Optional<java.util.Locale> getLocale()
- Returns:
- The locale of the message
-
getContentLength
default long getContentLength()
- Returns:
- The value of the Content-Length header or -1L if none specified
-
getContentType
@NonNull default java.util.Optional<MediaType> getContentType()
The request or response content type.- Returns:
- The content type
-
-