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:
MutableHttpRequestWrapper,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 acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.default MutableHttpRequest<B>accept(CharSequence... mediaTypes) Sets the acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.default MutableHttpRequest<B>basicAuth(CharSequence username, CharSequence password) Set anHttpHeaders.AUTHORIZATIONheader, with value: "Basic Base64(username:password)".default MutableHttpRequest<B>bearerAuth(CharSequence token) Set anHttpHeaders.AUTHORIZATIONheader, 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 MutableHttpRequest<B>Returns a mutable request based on this request.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, getAttributeMethods inherited from interface io.micronaut.core.convert.ConversionServiceAware
setConversionServiceMethods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentTypeMethods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute, setUserPrincipalMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttributeMethods 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:MutableHttpMessageSets the body.- Specified by:
bodyin interfaceMutableHttpMessage<B>- Type Parameters:
T- The new body type- Parameters:
body- The body- Returns:
- This message
-
getHeaders
MutableHttpHeaders getHeaders()- Specified by:
getHeadersin interfaceHttpMessage<B>- Specified by:
getHeadersin interfaceMutableHttpMessage<B>- Returns:
- The
HttpHeadersobject
-
getParameters
MutableHttpParameters getParameters()- Specified by:
getParametersin 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 acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.- Parameters:
mediaTypes- The media types- Returns:
- This request
-
accept
Sets the acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.- Parameters:
mediaTypes- The media types- Returns:
- This request
-
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
-
basicAuth
Description copied from interface:MutableHttpMessageSet anHttpHeaders.AUTHORIZATIONheader, with value: "Basic Base64(username:password)".- Specified by:
basicAuthin interfaceMutableHttpMessage<B>- Parameters:
username- The username part of the credentialspassword- The password part of the credentials- Returns:
- This response
-
bearerAuth
Description copied from interface:MutableHttpMessageSet anHttpHeaders.AUTHORIZATIONheader, with value: "Bearer token".- Specified by:
bearerAuthin interfaceMutableHttpMessage<B>- Parameters:
token- The token- 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
-
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
-
toMutableRequest
Description copied from interface:HttpRequestReturns a mutable request based on this request.- Specified by:
toMutableRequestin interfaceHttpRequest<B>- Returns:
- the mutable request
-