Package io.micronaut.http
Interface MutableHttpMessage<B>
- Type Parameters:
B
- The body type
- All Superinterfaces:
AttributeHolder
,HttpMessage<B>
,MutableAttributeHolder
- All Known Subinterfaces:
MutableHttpRequest<B>
,MutableHttpResponse<B>
- All Known Implementing Classes:
MutableHttpRequestWrapper
,NettyClientHttpRequest
,NettyMutableHttpResponse
,SimpleHttpRequest
An interface for an
HttpMessage
that is mutable allowing headers and the message body to be set.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault MutableHttpMessage<B>
basicAuth
(CharSequence username, CharSequence password) Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".default MutableHttpMessage<B>
bearerAuth
(CharSequence token) Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".<T> MutableHttpMessage<T>
body
(T body) Sets the body.default MutableHttpMessage<B>
bodyWriter
(MessageBodyWriter<B> messageBodyWriter) Sets the message body writer to use.default MutableHttpMessage<B>
contentEncoding
(CharSequence encoding) Sets the content encoding.default MutableHttpMessage<B>
contentLength
(long length) Sets the content length.default MutableHttpMessage<B>
contentType
(MediaType mediaType) Set the response content type.default MutableHttpMessage<B>
contentType
(CharSequence contentType) Set the response content type.default MutableHttpMessage<B>
header
(CharSequence name, CharSequence value) Set a response header.default MutableHttpMessage<B>
headers
(Consumer<MutableHttpHeaders> headers) Mutate the headers with the given consumer.default MutableHttpMessage<B>
headers
(Map<CharSequence, CharSequence> namesAndValues) Set multiple headers.Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocale, setAttribute
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
Method Details
-
bodyWriter
Sets the message body writer to use.- Parameters:
messageBodyWriter
- The message body writer.- Returns:
- This response
- Since:
- 4.0.0
-
getHeaders
MutableHttpHeaders getHeaders()- Specified by:
getHeaders
in interfaceHttpMessage<B>
- Returns:
- The
MutableHttpHeaders
object
-
body
Sets the body.- Type Parameters:
T
- The new body type- Parameters:
body
- The body- Returns:
- This message
-
headers
Mutate the headers with the given consumer.- Parameters:
headers
- The headers- Returns:
- This response
-
header
Set a response header.- Parameters:
name
- The name of the headervalue
- The value of the header- Returns:
- This response
-
basicAuth
Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".- Parameters:
username
- The username part of the credentialspassword
- The password part of the credentials- Returns:
- This response
-
bearerAuth
Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".- Parameters:
token
- The token- Returns:
- This response
-
headers
Set multiple headers.- Parameters:
namesAndValues
- The names and values- Returns:
- This response
-
contentLength
Sets the content length.- Parameters:
length
- The length- Returns:
- This response
-
contentType
Set the response content type.- Parameters:
contentType
- The content type- Returns:
- This response
-
contentType
Set the response content type.- Parameters:
mediaType
- The media type- Returns:
- This response
-
contentEncoding
Sets the content encoding.- Parameters:
encoding
- The encoding to use- Returns:
- This message
-