Package io.micronaut.http
Interface HttpRequest<B>
- Type Parameters:
B
- The Http message body
- All Superinterfaces:
AttributeHolder
,HttpMessage<B>
,MutableAttributeHolder
- All Known Subinterfaces:
FullHttpRequest<B>
,MutableHttpRequest<B>
,PushCapableHttpRequest<B>
- All Known Implementing Classes:
AbstractNettyHttpRequest
,HttpRequestWrapper
,NettyClientHttpRequest
,NettyHttpRequest
,SimpleHttpRequest
Common interface for HTTP request implementations.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault Collection<MediaType>
accept()
A list of acceptedMediaType
instances sorted by their quality rating.static <T> MutableHttpRequest<T>
create
(HttpMethod httpMethod, String uri) Create a newMutableHttpRequest
for the given method and URI.static <T> MutableHttpRequest<T>
create
(HttpMethod httpMethod, String uri, String httpMethodName) Create a newMutableHttpRequest
for the given method and URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.default Optional<Certificate>
Retrieves the Certificate used for mutual authentication.default HttpVersion
Get the origin header.getPath()
default @NonNull InetSocketAddress
default @NonNull InetSocketAddress
getUri()
The user principal stored within the request.getUserPrincipal
(Class<T> principalType) The user principal stored within the request.static MutableHttpRequest<?>
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.static MutableHttpRequest<?>
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.default boolean
isSecure()
default MutableHttpRequest<B>
mutate()
Returns a new request object that allows mutation.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.static <T> MutableHttpRequest<T>
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.default HttpRequest<B>
setAttribute
(CharSequence name, Object value) Sets an attribute on the message.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, getHeaders
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
Field Details
-
SCHEME_HTTP
Constant for HTTP scheme.- See Also:
-
SCHEME_HTTPS
Constant for HTTPS scheme.- See Also:
-
-
Method Details
-
getCookies
- Returns:
- The
Cookies
instance
-
getParameters
- Returns:
- The HTTP parameters contained with the URI query string
-
getMethod
- Returns:
- The request method
-
getUri
- Returns:
- The full request URI
-
mutate
Returns a new request object that allows mutation.- Returns:
- The mutable request
- Since:
- 2.0.0
-
getHttpVersion
- Returns:
- The http version of the request.
-
accept
A list of acceptedMediaType
instances sorted by their quality rating.- Returns:
- A list of zero or many
MediaType
instances
-
getMethodName
- Returns:
- The name of the method (same as
HttpMethod
value for standard http methods).
-
getUserPrincipal
The user principal stored within the request.- Returns:
- The principal
- Since:
- 1.0.4
-
getUserPrincipal
@NonNull default <T extends Principal> @NonNull Optional<T> getUserPrincipal(Class<T> principalType) The user principal stored within the request.- Type Parameters:
T
- The principal type- Parameters:
principalType
- The principal type- Returns:
- The principal
- Since:
- 1.0.4
-
getPath
- Returns:
- Get the raw, percent-encoded path without any parameters
-
getRemoteAddress
- Returns:
- Obtain the remote address
-
getServerAddress
- Returns:
- Obtain the server address
-
getServerName
- Returns:
- The server host name
-
isSecure
default boolean isSecure()- Returns:
- Is the request an HTTPS request
-
setAttribute
Description copied from interface:MutableAttributeHolder
Sets an attribute on the message.- Specified by:
setAttribute
in interfaceHttpMessage<B>
- Specified by:
setAttribute
in interfaceMutableAttributeHolder
- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Returns:
- This message
-
getLocale
- Specified by:
getLocale
in interfaceHttpMessage<B>
- Returns:
- The locale of the message
-
getCertificate
Retrieves the Certificate used for mutual authentication.- Returns:
- A certificate used for authentication, if applicable.
-
getOrigin
Get the origin header.- Returns:
- The origin header
- See Also:
-
GET
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
GET
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
OPTIONS
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
OPTIONS
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
HEAD
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
HEAD
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
POST
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
POST
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
PUT
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
PUT
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
PATCH
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
PATCH
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
DELETE
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
DELETE
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
-
DELETE
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
DELETE
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
-
create
Create a newMutableHttpRequest
for the given method and URI.- Type Parameters:
T
- The Http request type- Parameters:
httpMethod
- The methoduri
- The URI- Returns:
- The request
-
create
Create a newMutableHttpRequest
for the given method and URI.- Type Parameters:
T
- The Http request type- Parameters:
httpMethod
- The methoduri
- The URIhttpMethodName
- Method name - for standard http methods is equal toEnum.name()
- Returns:
- The request
-