Package io.micronaut.servlet.engine
Class DefaultServletHttpRequest<B>
java.lang.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.http.HttpMessage<B>
,io.micronaut.http.HttpRequest<B>
,io.micronaut.http.ServerHttpRequest<B>
,ParsedBodyHolder<B>
,ServletExchange<jakarta.servlet.http.HttpServletRequest,
,jakarta.servlet.http.HttpServletResponse> ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,
,B> StreamedServletMessage<B,
,byte[]> org.reactivestreams.Publisher<byte[]>
@Internal
public final class DefaultServletHttpRequest<B>
extends Object
implements ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>, ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>, StreamedServletMessage<B,byte[]>, io.micronaut.http.ServerHttpRequest<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 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, Executor ioExecutor) Default constructor. -
Method Summary
Modifier and TypeMethodDescription@NonNull io.micronaut.http.body.ByteBody
byteBody()
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
io.micronaut.http.HttpVersion
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
isSecure()
io.micronaut.http.MutableHttpRequest<B>
mutate()
void
setParsedBody
(B body) Set the parsed body.void
subscribe
(org.reactivestreams.Subscriber<? super byte[]> s) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBodyWriter
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getOrigin, getPath, getSslSession, getUserPrincipal, setAttribute, toMutableRequest
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
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, Executor ioExecutor) Default constructor.- Parameters:
conversionService
- The servlet requestdelegate
- The servlet requestresponse
- The servlet responsecodecRegistry
- The codec registrybodyBuilder
- Body BuilderioExecutor
- Executor for blocking operations
-
-
Method Details
-
getConversionService
public io.micronaut.core.convert.ConversionService getConversionService()- Returns:
- The conversion service.
-
getHttpVersion
public io.micronaut.http.HttpVersion getHttpVersion()- Specified by:
getHttpVersion
in interfaceio.micronaut.http.HttpRequest<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>
-
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>
-
byteBody
@NonNull public @NonNull io.micronaut.http.body.ByteBody byteBody()- Specified by:
byteBody
in interfaceio.micronaut.http.ServerHttpRequest<B>
-