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 @NonNull MutableHttpResponse<B>cacheControl(@NonNull CacheControl cacheControl) Sets the HTTP Cache-Control header.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_LANGUAGEheader 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, getAttributeMethods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocaleMethods inherited from interface io.micronaut.http.HttpResponse
body, code, getCookie, getCookies, getStatus, header, reason, setAttribute, statusMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttributeMethods 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:
bodyin 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:MutableHttpMessageMutate the headers with the given consumer.- Specified by:
headersin interfaceMutableHttpMessage<B>- Parameters:
headers- The headers- Returns:
- This response
-
header
Description copied from interface:MutableHttpMessageSet a response header.- Specified by:
headerin interfaceMutableHttpMessage<B>- Parameters:
name- The name of the headervalue- The value of the header- Returns:
- This response
-
headers
Description copied from interface:MutableHttpMessageSet multiple headers.- Specified by:
headersin interfaceMutableHttpMessage<B>- Parameters:
namesAndValues- The names and values- Returns:
- This response
-
cacheControl
@NonNull default @NonNull MutableHttpResponse<B> cacheControl(@NonNull @NonNull CacheControl cacheControl) Sets the HTTP Cache-Control header.- Parameters:
cacheControl- Cache Control- Returns:
- This response object
- Since:
- 4.9.0
-
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:MutableHttpMessageSets the content length.- Specified by:
contentLengthin interfaceMutableHttpMessage<B>- Parameters:
length- The length- Returns:
- This response
-
contentType
Description copied from interface:MutableHttpMessageSet the response content type.- Specified by:
contentTypein interfaceMutableHttpMessage<B>- Parameters:
contentType- The content type- Returns:
- This response
-
contentType
Description copied from interface:MutableHttpMessageSet the response content type.- Specified by:
contentTypein interfaceMutableHttpMessage<B>- Parameters:
mediaType- The media type- Returns:
- This response
-
contentEncoding
Description copied from interface:MutableHttpMessageSets the content encoding.- Specified by:
contentEncodingin interfaceMutableHttpMessage<B>- Parameters:
encoding- The encoding to use- Returns:
- This message
-
locale
Sets the locale to use and will apply the appropriateHttpHeaders.CONTENT_LANGUAGEheader 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:HttpResponseReturns a mutable response based on this response.- Specified by:
toMutableResponsein interfaceHttpResponse<B>- Returns:
- the mutable response
-