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:
FullHttpRequest<B>,HttpRequest<B>,HttpResponse<B>,MutableHttpMessage<B>,MutableHttpRequest<B>,MutableHttpResponse<B>,PushCapableHttpRequest<B>
- All Known Implementing Classes:
HttpMessageWrapper,HttpRequestWrapper,HttpResponseWrapper,SimpleHttpRequest
public interface HttpMessage<B>
extends io.micronaut.core.attr.MutableAttributeHolder
Common interface for HTTP messages.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>AMutableConvertibleValuesof the attributes for this HTTP message.getBody()default <T> @NonNull Optional<T>getBody(@NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) Return the body, will use the provided conversion context if needed.default <T> @NonNull Optional<T>getBody(@NonNull io.micronaut.core.type.Argument<T> type) Return the body as the given type.default <T> @NonNull Optional<T>Return the body as the given type.default Optional<MessageBodyWriter<B>>default @NonNull Charsetdefault longThe request or response content type.@NonNull HttpHeadersdefault @NonNull HttpMessage<B>setAttribute(@NonNull CharSequence name, Object value) Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttributeMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
Method Details
-
getHeaders
- Returns:
- The
HttpHeadersobject
-
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
- Returns:
- The request body
-
getBodyWriter
- Returns:
- The body writer.
- Since:
- 4.0.0
-
getCharacterEncoding
- Returns:
- The request character encoding. Defaults to
StandardCharsets.UTF_8
-
setAttribute
@NonNull default @NonNull HttpMessage<B> setAttribute(@NonNull @NonNull CharSequence name, Object value) - Specified by:
setAttributein interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getBody
@NonNull default <T> @NonNull Optional<T> getBody(@NonNull @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> @NonNull Optional<T> getBody(@NonNull @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) Return the body, will use the provided conversion context if needed.- Type Parameters:
T- The generic type- Parameters:
conversionContext- The body conversion context- Returns:
- An
Optionalof the type orOptional.empty()if the body cannot be returned as the given type - Since:
- 4.0.0
-
getBody
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
- Returns:
- The locale of the message
-
getContentLength
default long getContentLength()- Returns:
- The value of the Content-Length header or -1L if none specified
-
getContentType
The request or response content type.- Returns:
- The content type
-