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
ConstructorsModifierConstructorDescriptionprotectedDefaultServletHttpRequest(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.ByteBodybyteBody()voidexecuteAsync(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 Charsetio.micronaut.http.codec.MediaTypeCodecRegistrylong@NonNull Optional<io.micronaut.http.MediaType>io.micronaut.core.convert.ConversionService@NonNull io.micronaut.http.cookie.Cookies@NonNull io.micronaut.http.HttpHeadersio.micronaut.http.HttpVersionReturns anInputStreamthat can be used to read the body of this HTTP request.@NonNull io.micronaut.http.HttpMethod@NonNull Stringjakarta.servlet.http.HttpServletRequest@NonNull io.micronaut.http.HttpParametersReturns aBufferedReaderthat can be used to read the text body of this HTTP request.@NonNull InetSocketAddressServletHttpRequest<jakarta.servlet.http.HttpServletRequest,? super Object> ServletHttpResponse<jakarta.servlet.http.HttpServletResponse,?> @NonNull InetSocketAddress@Nullable String@NonNull URIgetUri()booleanChecks if this request supports asynchronous operation.booleanisSecure()io.micronaut.http.MutableHttpRequest<B>mutate()voidsetParsedBody(B body) Set the parsed body.voidsubscribe(org.reactivestreams.Subscriber<? super byte[]> s) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttributeMethods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBodyWriterMethods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getOrigin, getPath, getSslSession, getUserPrincipal, setAttributeMethods 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:
getHttpVersionin 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:ServletHttpRequestChecks 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:
isAsyncSupportedin interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B> - Returns:
- true if this request supports asynchronous operation, false otherwise
-
executeAsync
Description copied from interface:ServletHttpRequestCauses 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:
executeAsyncin 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:
getBodyin interfaceio.micronaut.http.HttpMessage<B>
-
getUserPrincipal
- Specified by:
getUserPrincipalin interfaceio.micronaut.http.HttpRequest<B>
-
isSecure
public boolean isSecure()- Specified by:
isSecurein interfaceio.micronaut.http.HttpRequest<B>
-
getContentType
- Specified by:
getContentTypein interfaceio.micronaut.http.HttpMessage<B>
-
getContentLength
public long getContentLength()- Specified by:
getContentLengthin interfaceio.micronaut.http.HttpMessage<B>
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceio.micronaut.http.HttpRequest<B>
-
getServerAddress
- Specified by:
getServerAddressin interfaceio.micronaut.http.HttpRequest<B>
-
getServerName
- Specified by:
getServerNamein interfaceio.micronaut.http.HttpRequest<B>
-
getLocale
-
getCharacterEncoding
- Specified by:
getCharacterEncodingin interfaceio.micronaut.http.HttpMessage<B>
-
getContextPath
- Specified by:
getContextPathin interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B> - Returns:
- The context path of the request.
-
getInputStream
Description copied from interface:ServletHttpRequestReturns anInputStreamthat 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:
getInputStreamin interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B> - Returns:
- The input stream
- Throws:
IOException- if a validInputStreamcannot be returned for some reason.
-
getReader
Description copied from interface:ServletHttpRequestReturns aBufferedReaderthat can be used to read the text body of this HTTP request.- Specified by:
getReaderin interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B> - Returns:
- The reader
- Throws:
IOException- if a validBufferedReadercannot be returned for some reason.
-
getNativeRequest
public jakarta.servlet.http.HttpServletRequest getNativeRequest()- Specified by:
getNativeRequestin interfaceServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B> - Returns:
- The native request type
-
getCookies
@NonNull public @NonNull io.micronaut.http.cookie.Cookies getCookies()- Specified by:
getCookiesin interfaceio.micronaut.http.HttpRequest<B>
-
getParameters
@NonNull public @NonNull io.micronaut.http.HttpParameters getParameters()- Specified by:
getParametersin interfaceio.micronaut.http.HttpRequest<B>
-
mutate
- Specified by:
mutatein interfaceio.micronaut.http.HttpRequest<B>
-
getMethod
@NonNull public @NonNull io.micronaut.http.HttpMethod getMethod()- Specified by:
getMethodin interfaceio.micronaut.http.HttpRequest<B>
-
getMethodName
- Specified by:
getMethodNamein interfaceio.micronaut.http.HttpRequest<B>
-
getUri
- Specified by:
getUriin interfaceio.micronaut.http.HttpRequest<B>
-
getHeaders
@NonNull public @NonNull io.micronaut.http.HttpHeaders getHeaders()- Specified by:
getHeadersin interfaceio.micronaut.http.HttpMessage<B>
-
getAttributes
@NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()- Specified by:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceio.micronaut.http.HttpMessage<B>- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder
-
setParsedBody
Description copied from interface:ParsedBodyHolderSet the parsed body.- Specified by:
setParsedBodyin interfaceParsedBodyHolder<B>- Parameters:
body- the parsed body
-
getBody
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<B>
-
getRequest
- Specified by:
getRequestin interfaceServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse> - Returns:
- The request object
-
getResponse
- Specified by:
getResponsein 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:
subscribein interfaceorg.reactivestreams.Publisher<B>
-
byteBody
@NonNull public @NonNull io.micronaut.http.body.ByteBody byteBody()- Specified by:
byteBodyin interfaceio.micronaut.http.ServerHttpRequest<B>
-