Package io.micronaut.http
Interface MutableHttpRequest<B>
- Type Parameters:
B
- The request body type
- All Superinterfaces:
AttributeHolder
,ConversionServiceAware
,HttpMessage<B>
,HttpRequest<B>
,MutableAttributeHolder
,MutableHttpMessage<B>
- All Known Implementing Classes:
NettyClientHttpRequest
,SimpleHttpRequest
public interface MutableHttpRequest<B>
extends HttpRequest<B>, MutableHttpMessage<B>, ConversionServiceAware
An extended version of
HttpRequest
that allows mutating headers, the body etc.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
Method Summary
Modifier and TypeMethodDescriptiondefault MutableHttpRequest<B>
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.default MutableHttpRequest<B>
accept
(CharSequence... mediaTypes) Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.default MutableHttpRequest<B>
basicAuth
(CharSequence username, CharSequence password) Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".default MutableHttpRequest<B>
bearerAuth
(CharSequence token) Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".<T> MutableHttpRequest<T>
body
(T body) Sets the body.default MutableHttpRequest<B>
contentEncoding
(CharSequence encoding) Sets the content encoding.default MutableHttpRequest<B>
contentLength
(long length) Sets the content length.default MutableHttpRequest<B>
contentType
(MediaType mediaType) Set the response content type.default MutableHttpRequest<B>
contentType
(CharSequence contentType) Set the response content type.Sets the specified cookie on the request.default MutableHttpRequest<B>
Sets the specified cookies on the request.default MutableHttpRequest<B>
header
(CharSequence name, CharSequence value) Set a response header.default MutableHttpRequest<B>
headers
(Consumer<MutableHttpHeaders> headers) Mutate the headers with the given consumer.default MutableHttpRequest<B>
headers
(Map<CharSequence, CharSequence> namesAndValues) Set multiple headers.default @NonNull MutableHttpRequest<B>
uri
(@NonNull Consumer<UriBuilder> consumer) Alters the URI of the request with the given URI builder.Sets the uri on the request.Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.core.convert.ConversionServiceAware
setConversionService
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
bodyWriter
-
Method Details
-
cookie
Sets the specified cookie on the request.- Parameters:
cookie
- the Cookie to return to the client- Returns:
- The http request
-
cookies
Sets the specified cookies on the request.- Parameters:
cookies
- the Cookies to return to the client- Returns:
- The http request
-
uri
Sets the uri on the request.- Parameters:
uri
- The uri to call- Returns:
- The http request
-
body
Description copied from interface:MutableHttpMessage
Sets the body.- Specified by:
body
in interfaceMutableHttpMessage<B>
- Type Parameters:
T
- The new body type- Parameters:
body
- The body- Returns:
- This message
-
getHeaders
MutableHttpHeaders getHeaders()- Specified by:
getHeaders
in interfaceHttpMessage<B>
- Specified by:
getHeaders
in interfaceMutableHttpMessage<B>
- Returns:
- The
HttpHeaders
object
-
getParameters
MutableHttpParameters getParameters()- Specified by:
getParameters
in interfaceHttpRequest<B>
- Returns:
- The HTTP parameters contained with the URI query string
-
uri
@NonNull default @NonNull MutableHttpRequest<B> uri(@NonNull @NonNull Consumer<UriBuilder> consumer) Alters the URI of the request with the given URI builder.- Parameters:
consumer
- A consumer that accepts the URI- Returns:
- The modified request
-
accept
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.- Parameters:
mediaTypes
- The media types- Returns:
- This request
-
accept
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.- Parameters:
mediaTypes
- The media types- Returns:
- This request
-
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
-
basicAuth
Description copied from interface:MutableHttpMessage
Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".- Specified by:
basicAuth
in interfaceMutableHttpMessage<B>
- Parameters:
username
- The username part of the credentialspassword
- The password part of the credentials- Returns:
- This response
-
bearerAuth
Description copied from interface:MutableHttpMessage
Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".- Specified by:
bearerAuth
in interfaceMutableHttpMessage<B>
- Parameters:
token
- The token- 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
-
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
-