Package io.micronaut.http.server.netty
Class NettyHttpRequest<T>
java.lang.Object
io.netty.util.DefaultAttributeMap
io.micronaut.http.netty.AbstractNettyHttpRequest<T>
io.micronaut.http.server.netty.NettyHttpRequest<T>
- Type Parameters:
T- The type
- All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder,io.micronaut.core.attr.MutableAttributeHolder,io.micronaut.http.FullHttpRequest<T>,io.micronaut.http.HttpMessage<T>,io.micronaut.http.HttpRequest<T>,io.micronaut.http.netty.NettyHttpRequestBuilder,io.micronaut.http.PushCapableHttpRequest<T>,io.netty.util.AttributeMap
@Internal
public class NettyHttpRequest<T>
extends io.micronaut.http.netty.AbstractNettyHttpRequest<T>
implements io.micronaut.http.HttpRequest<T>, io.micronaut.http.PushCapableHttpRequest<T>, io.micronaut.http.FullHttpRequest<T>
Delegates to the Netty
HttpRequest instance.- Since:
- 1.0
-
Field Summary
Fields inherited from class io.micronaut.http.netty.AbstractNettyHttpRequest
conversionService, httpMethod, httpMethodName, nettyRequest, unvalidatedUrlFields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS -
Constructor Summary
ConstructorsConstructorDescriptionNettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest, ByteBody body, io.netty.channel.ChannelHandlerContext ctx, io.micronaut.core.convert.ConversionService environment, io.micronaut.http.server.HttpServerConfiguration serverConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddRouteWaitsFor(io.micronaut.core.execution.ExecutionFlow<?> executionFlow) io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>>final ByteBodybyteBody()Get the last byte body of this request, be it claimed or unclaimed.io.micronaut.core.io.buffer.ByteBuffer<?>contents()final FormRouteCompletergetAttribute(CharSequence name) io.micronaut.core.convert.value.MutableConvertibleValues<Object>getBody()<T1> Optional<T1>getBody(io.micronaut.core.convert.ArgumentConversionContext<T1> conversionContext) <T1> Optional<T1>io.netty.channel.ChannelHandlerContextlongOptional<io.micronaut.http.MediaType>io.micronaut.http.cookie.Cookiesio.micronaut.http.HttpHeadersio.micronaut.http.HttpVersionio.netty.handler.codec.http.HttpRequestfinal io.micronaut.core.execution.ExecutionFlow<?>final booleanprotected CharsetinitCharset(Charset characterEncoding) final booleanbooleanisFull()booleanisSecure()booleanfinal HttpBodylastBody()Get the last body of this request, of any type.io.micronaut.http.MutableHttpRequest<T>mutate()voidrelease()Release and cleanup resources.protected voidreleaseIfNecessary(Object value) final ByteBodyrootBody()Get the initial body of this request.io.micronaut.http.PushCapableHttpRequest<T>serverPush(@NonNull io.micronaut.http.HttpRequest<?> request) io.micronaut.http.HttpRequest<T>setAttribute(CharSequence name, Object value) io.netty.handler.codec.http.HttpRequestDeprecated.Optional<io.netty.handler.codec.http.HttpRequest>io.netty.handler.codec.http.HttpRequesttoString()Methods inherited from class io.micronaut.http.netty.AbstractNettyHttpRequest
createDecoder, getCharacterEncoding, getMethod, getMethodName, getNettyRequest, getParameters, getPath, getUri, isStream, toFullHttpRequest, toStreamHttpRequestMethods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttrMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttributeMethods inherited from interface io.micronaut.http.HttpMessage
getBody, getBodyWriter, getCharacterEncodingMethods inherited from interface io.micronaut.http.HttpRequest
accept, getLocale, getMethod, getMethodName, getParameters, getPath, getUri, getUserPrincipal, getUserPrincipalMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
-
Constructor Details
-
NettyHttpRequest
public NettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest, ByteBody body, io.netty.channel.ChannelHandlerContext ctx, io.micronaut.core.convert.ConversionService environment, io.micronaut.http.server.HttpServerConfiguration serverConfiguration) throws IllegalArgumentException - Parameters:
nettyRequest- TheHttpRequestbody- The request bodyctx- TheChannelHandlerContextenvironment- The EnvironmentserverConfiguration- TheHttpServerConfiguration- Throws:
IllegalArgumentException- When the request URI is invalid
-
-
Method Details
-
rootBody
Get the initial body of this request. This is always aByteBody. In most cases you should usebyteBody()instead.- Returns:
- The root body
-
byteBody
Get the last byte body of this request, be it claimed or unclaimed. Basically, there are two options: For buffered requests (rootBody is immediate), this is just the root body. For streaming requests (rootBody is streaming), this can be that root body, or if someone calledByteBody.buffer(io.netty.buffer.ByteBufAllocator)(and the buffering has completed), it can be the buffered immediate body.
The returned byte body may have been claimed already.- Returns:
- The byte body of this request
-
lastBody
Get the last body of this request, of any type. This is a weird method to use, avoid it. It's sometimes necessary to "piggyback" off other code that parses the body. For example ingetBody(), we want to return whatever we can, even if the body has already been claimed for a@Bodyparameter or form parsing or something. So we take the last step in the parse chain and do our best with it.- Returns:
- The last body of this request
-
addRouteWaitsFor
public final void addRouteWaitsFor(io.micronaut.core.execution.ExecutionFlow<?> executionFlow) -
getRouteWaitsFor
public final io.micronaut.core.execution.ExecutionFlow<?> getRouteWaitsFor() -
formRouteCompleter
-
hasFormRouteCompleter
public final boolean hasFormRouteCompleter() -
mutate
- Specified by:
mutatein interfaceio.micronaut.http.HttpRequest<T>
-
getAttribute
- Specified by:
getAttributein interfaceio.micronaut.core.attr.AttributeHolder
-
getHttpVersion
public io.micronaut.http.HttpVersion getHttpVersion()- Specified by:
getHttpVersionin interfaceio.micronaut.http.HttpRequest<T>
-
toString
-
getNativeRequest
public io.netty.handler.codec.http.HttpRequest getNativeRequest()- Returns:
- Obtain a reference to the native Netty HTTP request
-
getChannelHandlerContext
public io.netty.channel.ChannelHandlerContext getChannelHandlerContext()- Returns:
- The
ChannelHandlerContext
-
getCookies
public io.micronaut.http.cookie.Cookies getCookies()- Specified by:
getCookiesin interfaceio.micronaut.http.HttpRequest<T>
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceio.micronaut.http.HttpRequest<T>
-
getServerAddress
- Specified by:
getServerAddressin interfaceio.micronaut.http.HttpRequest<T>
-
getServerName
- Specified by:
getServerNamein interfaceio.micronaut.http.HttpRequest<T>
-
isSecure
public boolean isSecure()- Specified by:
isSecurein interfaceio.micronaut.http.HttpRequest<T>
-
getOrigin
- Specified by:
getOriginin interfaceio.micronaut.http.HttpRequest<T>
-
getHeaders
public io.micronaut.http.HttpHeaders getHeaders()- Specified by:
getHeadersin interfaceio.micronaut.http.HttpMessage<T>
-
getAttributes
- Specified by:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceio.micronaut.http.HttpMessage<T>- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder
-
setAttribute
-
getCertificate
- Specified by:
getCertificatein interfaceio.micronaut.http.HttpRequest<T>
-
getBody
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
getBody
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
getBody
public <T1> Optional<T1> getBody(io.micronaut.core.convert.ArgumentConversionContext<T1> conversionContext) - Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
release
@Internal public void release()Release and cleanup resources. -
releaseIfNecessary
- Parameters:
value- An object with a value
-
isServerPushSupported
public boolean isServerPushSupported()- Specified by:
isServerPushSupportedin interfaceio.micronaut.http.PushCapableHttpRequest<T>
-
serverPush
public io.micronaut.http.PushCapableHttpRequest<T> serverPush(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request) - Specified by:
serverPushin interfaceio.micronaut.http.PushCapableHttpRequest<T>
-
initCharset
- Specified by:
initCharsetin classio.micronaut.http.netty.AbstractNettyHttpRequest<T>
-
isFormOrMultipartData
@Internal public final boolean isFormOrMultipartData()- Returns:
- Return true if the request is form data.
-
toHttpRequest
Deprecated.- Specified by:
toHttpRequestin interfaceio.micronaut.http.netty.NettyHttpRequestBuilder- Overrides:
toHttpRequestin classio.micronaut.http.netty.AbstractNettyHttpRequest<T>
-
toHttpRequestDirect
- Specified by:
toHttpRequestDirectin interfaceio.micronaut.http.netty.NettyHttpRequestBuilder
-
toHttpRequestWithoutBody
public io.netty.handler.codec.http.HttpRequest toHttpRequestWithoutBody()- Specified by:
toHttpRequestWithoutBodyin interfaceio.micronaut.http.netty.NettyHttpRequestBuilder
-
getContentType
- Specified by:
getContentTypein interfaceio.micronaut.http.HttpMessage<T>
-
getContentLength
public long getContentLength()- Specified by:
getContentLengthin interfaceio.micronaut.http.HttpMessage<T>
-
isFull
public boolean isFull()- Specified by:
isFullin interfaceio.micronaut.http.FullHttpRequest<T>
-
contents
public io.micronaut.core.io.buffer.ByteBuffer<?> contents()- Specified by:
contentsin interfaceio.micronaut.http.FullHttpRequest<T>
-
bufferContents
public io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>> bufferContents()- Specified by:
bufferContentsin interfaceio.micronaut.http.FullHttpRequest<T>
-