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>,- ServerHttpRequest<B>
- All Known Implementing Classes:
- AbstractNettyHttpRequest,- HttpRequestWrapper,- MutableHttpRequestWrapper,- NettyClientHttpRequest,- NettyHttpRequest,- SimpleHttpRequest
Common interface for HTTP request implementations.
- Since:
- 1.0
- Author:
- Graeme Rocher
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptiondefault Collection<MediaType>accept()A list of acceptedMediaTypeinstances sorted by their quality rating.static <T> MutableHttpRequest<T>create(HttpMethod httpMethod, String uri) Create a newMutableHttpRequestfor the given method and URI.static <T> MutableHttpRequest<T>create(HttpMethod httpMethod, String uri, String httpMethodName) Create a newMutableHttpRequestfor the given method and URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.default Optional<Certificate>Retrieves the Certificate used for mutual authentication.default HttpVersionGet the origin header.getPath()default @NonNull InetSocketAddressdefault @NonNull InetSocketAddressdefault Optional<SSLSession>Get the SSL session used for the connection to the client, if available.getUri()The user principal stored within the request.getUserPrincipal(Class<T> principalType) The user principal stored within the request.static MutableHttpRequest<?>Return aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.static MutableHttpRequest<?>Return aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.default booleanisSecure()default MutableHttpRequest<B>mutate()Returns a new request object that allows mutation.static <T> MutableHttpRequest<T>Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest for the given URI.static <T> MutableHttpRequest<T>Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest for the given URI.default HttpRequest<B>setAttribute(CharSequence name, Object value) Sets an attribute on the message.default voidsetUserPrincipal(@Nullable Principal principal) Set the user principal.default MutableHttpRequest<B>Returns a mutable request based on this request.Methods inherited from interface io.micronaut.core.attr.AttributeHoldergetAttribute, getAttributeMethods inherited from interface io.micronaut.http.HttpMessagegetAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getHeadersMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolderremoveAttribute
- 
Field Details- 
SCHEME_HTTPConstant for HTTP scheme.- See Also:
 
- 
SCHEME_HTTPSConstant for HTTPS scheme.- See Also:
 
 
- 
- 
Method Details- 
getCookies- Returns:
- The Cookiesinstance
 
- 
getParameters- Returns:
- The HTTP parameters contained with the URI query string
 
- 
getMethod- Returns:
- The request method
 
- 
getUri- Returns:
- The full request URI
 
- 
mutateReturns a new request object that allows mutation.- Returns:
- The mutable request
- Since:
- 2.0.0
 
- 
getHttpVersion- Returns:
- The http version of the request.
 
- 
acceptA list of acceptedMediaTypeinstances sorted by their quality rating.- Returns:
- A list of zero or many MediaTypeinstances
 
- 
getMethodName- Returns:
- The name of the method (same as HttpMethodvalue for standard http methods).
 
- 
getUserPrincipalThe 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
 
- 
setUserPrincipalSet the user principal.- Parameters:
- principal- The principal
- Since:
- 4.8.0
 
- 
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
 
- 
isSecuredefault boolean isSecure()- Returns:
- Is the request an HTTPS request
 
- 
setAttributeDescription copied from interface:MutableAttributeHolderSets an attribute on the message.- Specified by:
- setAttributein interface- HttpMessage<B>
- Specified by:
- setAttributein interface- MutableAttributeHolder
- Parameters:
- name- The name of the attribute
- value- The value of the attribute
- Returns:
- This message
 
- 
getLocale- Specified by:
- getLocalein interface- HttpMessage<B>
- Returns:
- The locale of the message
 
- 
getCertificateRetrieves the Certificate used for mutual authentication.- Returns:
- A certificate used for authentication, if applicable.
 
- 
getSslSessionGet the SSL session used for the connection to the client, if available.- Returns:
- The session
 
- 
getOriginGet the origin header.- Returns:
- The origin header
- See Also:
 
- 
GETReturn aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
GETReturn aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
OPTIONSReturn aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
OPTIONSReturn aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
HEADReturn aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
HEADReturn aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
POSTReturn aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
POSTReturn aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
PUTReturn aMutableHttpRequestthat executes anHttpMethod.PUTrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
PUTReturn aMutableHttpRequestthat executes anHttpMethod.PUTrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
PATCHReturn aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
PATCHReturn aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
DELETEReturn aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
DELETEReturn aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
- T- The body type
- Parameters:
- uri- The URI
- body- The body of the request (content type defaults to- MediaType.APPLICATION_JSON
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
DELETEReturn aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
DELETEReturn aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
- T- The Http request type
- Parameters:
- uri- The URI
- Returns:
- The MutableHttpRequestinstance
- See Also:
 
- 
createCreate a newMutableHttpRequestfor the given method and URI.- Type Parameters:
- T- The Http request type
- Parameters:
- httpMethod- The method
- uri- The URI
- Returns:
- The request
 
- 
createCreate a newMutableHttpRequestfor the given method and URI.- Type Parameters:
- T- The Http request type
- Parameters:
- httpMethod- The method
- uri- The URI
- httpMethodName- Method name - for standard http methods is equal to- Enum.name()
- Returns:
- The request
 
- 
toMutableRequestReturns a mutable request based on this request.- Returns:
- the mutable request
- Since:
- 4.7
 
 
-