Package io.micronaut.http
Interface MutableHttpResponse<B>
- Type Parameters:
B
- The body response type
- All Superinterfaces:
AttributeHolder
,HttpMessage<B>
,HttpResponse<B>
,MutableAttributeHolder
,MutableHttpMessage<B>
- All Known Implementing Classes:
NettyMutableHttpResponse
A version of the
HttpResponse
interface that is mutable allowing the ability to set headers,
character encoding etc.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault MutableHttpResponse<B>
attribute
(CharSequence name, Object value) Sets an attribute on the response.<T> MutableHttpResponse<T>
body
(T body) Sets the body.default MutableHttpResponse<B>
characterEncoding
(CharSequence encoding) Sets the response encoding.default MutableHttpResponse<B>
characterEncoding
(Charset encoding) Sets the response encoding.default MutableHttpResponse<B>
contentEncoding
(CharSequence encoding) Sets the content encoding.default MutableHttpResponse<B>
contentLength
(long length) Sets the content length.default MutableHttpResponse<B>
contentType
(MediaType mediaType) Set the response content type.default MutableHttpResponse<B>
contentType
(CharSequence contentType) Set the response content type.Adds the specified cookie to the response.default MutableHttpResponse<B>
Adds the specified cookies to the response.default MutableHttpResponse<B>
header
(CharSequence name, CharSequence value) Set a response header.default MutableHttpResponse<B>
headers
(Consumer<MutableHttpHeaders> headers) Mutate the headers with the given consumer.default MutableHttpResponse<B>
headers
(Map<CharSequence, CharSequence> namesAndValues) Set multiple headers.default MutableHttpResponse<B>
Sets the locale to use and will apply the appropriateHttpHeaders.CONTENT_LANGUAGE
header to the response.default MutableHttpResponse<B>
status
(int status) Sets the response status.status
(int status, CharSequence message) Sets the response status.default MutableHttpResponse<B>
status
(HttpStatus status) Sets the response status.default MutableHttpResponse<B>
status
(HttpStatus status, CharSequence message) Sets the response status.default MutableHttpResponse<?>
Returns a mutable response based on this response.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
Methods inherited from interface io.micronaut.http.HttpResponse
body, code, getCookie, getCookies, getStatus, header, reason, setAttribute, status
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
basicAuth, bearerAuth, bodyWriter, getHeaders
-
Method Details
-
cookie
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.- Parameters:
cookie
- the Cookie to return to the client- Returns:
- This response object
-
cookies
Adds the specified cookies to the response.- Parameters:
cookies
- the Set of Cookies to return to the client- Returns:
- This response object
-
body
Sets the body.- Specified by:
body
in interfaceMutableHttpMessage<B>
- Type Parameters:
T
- The new body type- Parameters:
body
- The body- Returns:
- This response object
-
status
Sets the response status.- Parameters:
status
- The statusmessage
- The message- Returns:
- This response object
-
headers
Description copied from interface:MutableHttpMessage
Mutate the headers with the given consumer.- Specified by:
headers
in interfaceMutableHttpMessage<B>
- Parameters:
headers
- The headers- Returns:
- This response
-
header
Description copied from interface:MutableHttpMessage
Set a response header.- Specified by:
header
in interfaceMutableHttpMessage<B>
- Parameters:
name
- The name of the headervalue
- The value of the header- Returns:
- This response
-
headers
Description copied from interface:MutableHttpMessage
Set multiple headers.- Specified by:
headers
in interfaceMutableHttpMessage<B>
- Parameters:
namesAndValues
- The names and values- Returns:
- This response
-
characterEncoding
Sets the response encoding. Should be called aftercontentType(MediaType)
.- Parameters:
encoding
- The encoding to use- Returns:
- This response object
-
characterEncoding
Sets the response encoding.- Parameters:
encoding
- The encoding to use- Returns:
- The encoded reponse object
-
contentLength
Description copied from interface:MutableHttpMessage
Sets the content length.- Specified by:
contentLength
in interfaceMutableHttpMessage<B>
- Parameters:
length
- The length- Returns:
- This response
-
contentType
Description copied from interface:MutableHttpMessage
Set the response content type.- Specified by:
contentType
in interfaceMutableHttpMessage<B>
- Parameters:
contentType
- The content type- Returns:
- This response
-
contentType
Description copied from interface:MutableHttpMessage
Set the response content type.- Specified by:
contentType
in interfaceMutableHttpMessage<B>
- Parameters:
mediaType
- The media type- Returns:
- This response
-
contentEncoding
Description copied from interface:MutableHttpMessage
Sets the content encoding.- Specified by:
contentEncoding
in interfaceMutableHttpMessage<B>
- Parameters:
encoding
- The encoding to use- Returns:
- This message
-
locale
Sets the locale to use and will apply the appropriateHttpHeaders.CONTENT_LANGUAGE
header to the response.- Parameters:
locale
- The locale- Returns:
- This response object
-
status
Sets the response status.- Parameters:
status
- The status- Returns:
- This response object
-
status
Sets the response status.- Parameters:
status
- The statusmessage
- The message- Returns:
- This response object
-
status
Sets the response status.- Parameters:
status
- The status- Returns:
- This response object
-
attribute
Sets an attribute on the response.- Parameters:
name
- The attribute namevalue
- The attribute value- Returns:
- This response object
-
toMutableResponse
Description copied from interface:HttpResponse
Returns a mutable response based on this response.- Specified by:
toMutableResponse
in interfaceHttpResponse<B>
- Returns:
- the mutable response
-