Package io.micronaut.servlet.engine
Class DefaultServletHttpRequest<B>
java.lang.Object
io.micronaut.core.convert.value.ConvertibleValuesMap<V>
io.micronaut.core.convert.value.MutableConvertibleValuesMap<Object>
io.micronaut.servlet.engine.DefaultServletHttpRequest<B>
- Type Parameters:
B
- The body type
- All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder
,io.micronaut.core.attr.MutableAttributeHolder
,io.micronaut.core.convert.ConversionServiceAware
,io.micronaut.core.convert.ConversionServiceProvider
,io.micronaut.core.convert.value.ConvertibleValues<Object>
,io.micronaut.core.convert.value.MutableConvertibleValues<Object>
,io.micronaut.core.value.ValueResolver<CharSequence>
,io.micronaut.http.FullHttpRequest<B>
,io.micronaut.http.HttpMessage<B>
,io.micronaut.http.HttpRequest<B>
,ParsedBodyHolder<B>
,ServletExchange<jakarta.servlet.http.HttpServletRequest,
,jakarta.servlet.http.HttpServletResponse> ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
,B> StreamedServletMessage<B,
,byte[]> Iterable<Map.Entry<String,
,Object>> org.reactivestreams.Publisher<byte[]>
@Internal
public final class DefaultServletHttpRequest<B>
extends io.micronaut.core.convert.value.MutableConvertibleValuesMap<Object>
implements ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>, io.micronaut.core.convert.value.MutableConvertibleValues<Object>, ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>, StreamedServletMessage<B,byte[]>, io.micronaut.http.FullHttpRequest<B>, ParsedBodyHolder<B>
Implementation of
HttpRequest
ontop of the Servlet API.- Since:
- 1.0.0
- Author:
- graemerocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.servlet.http.ServletHttpRequest
ServletHttpRequest.AsyncExecution, ServletHttpRequest.AsyncExecutionCallback
-
Field Summary
Fields inherited from class io.micronaut.core.convert.value.ConvertibleValuesMap
map
Fields inherited from interface io.micronaut.core.convert.value.ConvertibleValues
EMPTY
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultServletHttpRequest
(io.micronaut.core.convert.ConversionService conversionService, jakarta.servlet.http.HttpServletRequest delegate, jakarta.servlet.http.HttpServletResponse response, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, BodyBuilder bodyBuilder) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>>
io.micronaut.core.io.buffer.ByteBuffer<?>
contents()
void
executeAsync
(ServletHttpRequest.AsyncExecutionCallback asyncExecutionCallback) Causes the container to dispatch a thread, possibly from a managed thread pool, to run the specifiedServletHttpRequest.AsyncExecutionCallback
.@NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>
getBody()
<T> @NonNull Optional<T>
getBody
(@NonNull io.micronaut.core.type.Argument<T> arg) @NonNull Charset
io.micronaut.http.codec.MediaTypeCodecRegistry
long
@NonNull Optional<io.micronaut.http.MediaType>
io.micronaut.core.convert.ConversionService
@NonNull io.micronaut.http.cookie.Cookies
@NonNull io.micronaut.http.HttpHeaders
Returns anInputStream
that can be used to read the body of this HTTP request.@NonNull io.micronaut.http.HttpMethod
@NonNull String
jakarta.servlet.http.HttpServletRequest
@NonNull io.micronaut.http.HttpParameters
Returns aBufferedReader
that can be used to read the text body of this HTTP request.@NonNull InetSocketAddress
ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
? super Object> ServletHttpResponse<jakarta.servlet.http.HttpServletResponse,
?> @NonNull InetSocketAddress
@Nullable String
@NonNull URI
getUri()
boolean
Checks if this request supports asynchronous operation.boolean
isFull()
boolean
isSecure()
io.micronaut.http.MutableHttpRequest<B>
mutate()
io.micronaut.core.convert.value.MutableConvertibleValues<Object>
put
(CharSequence key, @Nullable Object value) void
setParsedBody
(B body) Set the parsed body.void
subscribe
(org.reactivestreams.Subscriber<? super byte[]> s) Methods inherited from class io.micronaut.core.convert.value.MutableConvertibleValuesMap
clear, remove, toString
Methods inherited from class io.micronaut.core.convert.value.ConvertibleValuesMap
contains, empty, equals, get, getValue, hashCode, names, setConversionService, values
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.core.convert.value.ConvertibleValues
asMap, asMap, asProperties, contains, forEach, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, values
Methods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBodyWriter
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getHttpVersion, getOrigin, getPath, getUserPrincipal, setAttribute
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.core.convert.value.MutableConvertibleValues
clear, putAll, putAll, remove
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get, get
-
Constructor Details
-
DefaultServletHttpRequest
protected DefaultServletHttpRequest(io.micronaut.core.convert.ConversionService conversionService, jakarta.servlet.http.HttpServletRequest delegate, jakarta.servlet.http.HttpServletResponse response, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, BodyBuilder bodyBuilder) Default constructor.- Parameters:
conversionService
- The servlet requestdelegate
- The servlet requestresponse
- The servlet responsecodecRegistry
- The codec registrybodyBuilder
- Body Builder
-
-
Method Details
-
getConversionService
public io.micronaut.core.convert.ConversionService getConversionService()- Specified by:
getConversionService
in interfaceio.micronaut.core.convert.ConversionServiceProvider
- Specified by:
getConversionService
in interfaceio.micronaut.core.convert.value.ConvertibleValues<B>
-
getCodecRegistry
public io.micronaut.http.codec.MediaTypeCodecRegistry getCodecRegistry()- Returns:
- The codec registry.
-
isAsyncSupported
public boolean isAsyncSupported()Description copied from interface:ServletHttpRequest
Checks if this request supports asynchronous operation.Asynchronous operation is disabled for this request if this request is within the scope of a filter or servlet that has not been annotated or flagged in the deployment descriptor as being able to support asynchronous handling.
- Specified by:
isAsyncSupported
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Returns:
- true if this request supports asynchronous operation, false otherwise
-
executeAsync
Description copied from interface:ServletHttpRequest
Causes the container to dispatch a thread, possibly from a managed thread pool, to run the specifiedServletHttpRequest.AsyncExecutionCallback
. After the execution is completeServletHttpRequest.AsyncExecution.complete()
should be called.- Specified by:
executeAsync
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Parameters:
asyncExecutionCallback
- The response publisher
-
getBody
@NonNull public <T> @NonNull Optional<T> getBody(@NonNull @NonNull io.micronaut.core.type.Argument<T> arg) - Specified by:
getBody
in interfaceio.micronaut.http.HttpMessage<B>
-
getUserPrincipal
- Specified by:
getUserPrincipal
in interfaceio.micronaut.http.HttpRequest<B>
-
isSecure
public boolean isSecure()- Specified by:
isSecure
in interfaceio.micronaut.http.HttpRequest<B>
-
getContentType
- Specified by:
getContentType
in interfaceio.micronaut.http.HttpMessage<B>
-
getContentLength
public long getContentLength()- Specified by:
getContentLength
in interfaceio.micronaut.http.HttpMessage<B>
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceio.micronaut.http.HttpRequest<B>
-
getServerAddress
- Specified by:
getServerAddress
in interfaceio.micronaut.http.HttpRequest<B>
-
getServerName
- Specified by:
getServerName
in interfaceio.micronaut.http.HttpRequest<B>
-
getLocale
-
getCharacterEncoding
- Specified by:
getCharacterEncoding
in interfaceio.micronaut.http.HttpMessage<B>
-
getContextPath
- Specified by:
getContextPath
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Returns:
- The context path of the request.
-
getInputStream
Description copied from interface:ServletHttpRequest
Returns anInputStream
that can be used to read the body of this HTTP request. This method is typically used to read binary data. If the body is text, theServletHttpRequest.getReader()
method is more appropriate.- Specified by:
getInputStream
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Returns:
- The input stream
- Throws:
IOException
- if a validInputStream
cannot be returned for some reason.
-
getReader
Description copied from interface:ServletHttpRequest
Returns aBufferedReader
that can be used to read the text body of this HTTP request.- Specified by:
getReader
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Returns:
- The reader
- Throws:
IOException
- if a validBufferedReader
cannot be returned for some reason.
-
getNativeRequest
public jakarta.servlet.http.HttpServletRequest getNativeRequest()- Specified by:
getNativeRequest
in interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
B> - Returns:
- The native request type
-
getCookies
@NonNull public @NonNull io.micronaut.http.cookie.Cookies getCookies()- Specified by:
getCookies
in interfaceio.micronaut.http.HttpRequest<B>
-
getParameters
@NonNull public @NonNull io.micronaut.http.HttpParameters getParameters()- Specified by:
getParameters
in interfaceio.micronaut.http.HttpRequest<B>
-
mutate
- Specified by:
mutate
in interfaceio.micronaut.http.HttpRequest<B>
-
getMethod
@NonNull public @NonNull io.micronaut.http.HttpMethod getMethod()- Specified by:
getMethod
in interfaceio.micronaut.http.HttpRequest<B>
-
getMethodName
- Specified by:
getMethodName
in interfaceio.micronaut.http.HttpRequest<B>
-
getUri
- Specified by:
getUri
in interfaceio.micronaut.http.HttpRequest<B>
-
getHeaders
@NonNull public @NonNull io.micronaut.http.HttpHeaders getHeaders()- Specified by:
getHeaders
in interfaceio.micronaut.http.HttpMessage<B>
-
getAttributes
@NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.AttributeHolder
- Specified by:
getAttributes
in interfaceio.micronaut.http.HttpMessage<B>
- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.MutableAttributeHolder
-
setParsedBody
Description copied from interface:ParsedBodyHolder
Set the parsed body.- Specified by:
setParsedBody
in interfaceParsedBodyHolder<B>
- Parameters:
body
- the parsed body
-
getBody
- Specified by:
getBody
in interfaceio.micronaut.http.HttpMessage<B>
-
put
public io.micronaut.core.convert.value.MutableConvertibleValues<Object> put(CharSequence key, @Nullable @Nullable Object value) -
getRequest
- Specified by:
getRequest
in interfaceServletExchange<jakarta.servlet.http.HttpServletRequest,
jakarta.servlet.http.HttpServletResponse> - Returns:
- The request object
-
getResponse
- Specified by:
getResponse
in interfaceServletExchange<jakarta.servlet.http.HttpServletRequest,
jakarta.servlet.http.HttpServletResponse> - Returns:
- The response object
-
subscribe
public void subscribe(org.reactivestreams.Subscriber<? super byte[]> s) - Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<B>
-
isFull
public boolean isFull()- Specified by:
isFull
in interfaceio.micronaut.http.FullHttpRequest<B>
-
contents
public io.micronaut.core.io.buffer.ByteBuffer<?> contents()- Specified by:
contents
in interfaceio.micronaut.http.FullHttpRequest<B>
-
bufferContents
public io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>> bufferContents()- Specified by:
bufferContents
in interfaceio.micronaut.http.FullHttpRequest<B>
-