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.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>Delegates to the NettyHttpRequestinstance.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description NettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest, io.netty.channel.ChannelHandlerContext ctx, io.micronaut.core.convert.ConversionService environment, io.micronaut.http.server.HttpServerConfiguration serverConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContent(io.netty.buffer.ByteBufHolder httpContent)protected java.lang.ObjectbuildBody()java.util.Optional<java.lang.Object>getAttribute(java.lang.CharSequence name)io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>getAttributes()java.util.Optional<T>getBody()<T1> java.util.Optional<T1>getBody(io.micronaut.core.type.Argument<T1> type)<T1> java.util.Optional<T1>getBody(java.lang.Class<T1> type)io.netty.channel.ChannelHandlerContextgetChannelHandlerContext()io.micronaut.http.cookie.CookiesgetCookies()io.micronaut.http.HttpHeadersgetHeaders()io.micronaut.web.router.RouteMatch<?>getMatchedRoute()io.netty.handler.codec.http.HttpRequestgetNativeRequest()java.net.InetSocketAddressgetRemoteAddress()java.net.InetSocketAddressgetServerAddress()java.lang.StringgetServerName()protected java.nio.charset.CharsetinitCharset(java.nio.charset.Charset characterEncoding)booleanisSecure()booleanisServerPushSupported()io.micronaut.http.MutableHttpRequest<T>mutate()voidprepareHttp2ResponseIfNecessary(io.netty.handler.codec.http.HttpResponse finalResponse)Prepares a response based on this HTTP/2 request if HTTP/2 is enabled.voidrelease()Release and cleanup resources.protected voidreleaseIfNecessary(java.lang.Object value)io.micronaut.http.PushCapableHttpRequest<T>serverPush(io.micronaut.http.HttpRequest<?> request)voidsetBody(T body)Sets the body.java.lang.StringtoString()-
Methods inherited from class io.micronaut.http.netty.AbstractNettyHttpRequest
accept, createDecoder, getCharacterEncoding, getContentType, getHttpVersion, getLocale, getMethod, getMethodName, getNettyRequest, getParameters, getPath, getUri, isStream, toFullHttpRequest, toHttpRequest, toStreamHttpRequest
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.micronaut.http.HttpMessage
getCharacterEncoding, getContentLength, getContentType
-
-
-
-
Constructor Detail
-
NettyHttpRequest
public NettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest, io.netty.channel.ChannelHandlerContext ctx, io.micronaut.core.convert.ConversionService environment, io.micronaut.http.server.HttpServerConfiguration serverConfiguration)- Parameters:
nettyRequest- TheHttpRequestctx- TheChannelHandlerContextenvironment- The EnvironmentserverConfiguration- TheHttpServerConfiguration
-
-
Method Detail
-
prepareHttp2ResponseIfNecessary
@Internal public final void prepareHttp2ResponseIfNecessary(@NonNull io.netty.handler.codec.http.HttpResponse finalResponse)Prepares a response based on this HTTP/2 request if HTTP/2 is enabled.- Parameters:
finalResponse- The response to prepare, nevernull
-
mutate
public io.micronaut.http.MutableHttpRequest<T> mutate()
- Specified by:
mutatein interfaceio.micronaut.http.HttpRequest<T>
-
getAttribute
@NonNull public java.util.Optional<java.lang.Object> getAttribute(java.lang.CharSequence name)
- Specified by:
getAttributein interfaceio.micronaut.core.attr.AttributeHolder
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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
public java.net.InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceio.micronaut.http.HttpRequest<T>
-
getServerAddress
public java.net.InetSocketAddress getServerAddress()
- Specified by:
getServerAddressin interfaceio.micronaut.http.HttpRequest<T>
-
getServerName
public java.lang.String getServerName()
- Specified by:
getServerNamein interfaceio.micronaut.http.HttpRequest<T>
-
isSecure
public boolean isSecure()
- Specified by:
isSecurein interfaceio.micronaut.http.HttpRequest<T>
-
getHeaders
public io.micronaut.http.HttpHeaders getHeaders()
- Specified by:
getHeadersin interfaceio.micronaut.http.HttpMessage<T>
-
getAttributes
public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> 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
-
getBody
public java.util.Optional<T> getBody()
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
buildBody
protected java.lang.Object buildBody()
- Returns:
- A
CompositeByteBuf
-
getBody
public <T1> java.util.Optional<T1> getBody(java.lang.Class<T1> type)
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
getBody
public <T1> java.util.Optional<T1> getBody(io.micronaut.core.type.Argument<T1> type)
- Specified by:
getBodyin interfaceio.micronaut.http.HttpMessage<T>
-
release
@Internal public void release()
Release and cleanup resources.
-
releaseIfNecessary
protected void releaseIfNecessary(java.lang.Object value)
- Parameters:
value- An object with a value
-
setBody
@Internal public void setBody(T body)
Sets the body.- Parameters:
body- The body to set
-
getMatchedRoute
@Internal public io.micronaut.web.router.RouteMatch<?> getMatchedRoute()
- Returns:
- Obtains the matched route
-
addContent
@Internal public void addContent(io.netty.buffer.ByteBufHolder httpContent)
- Parameters:
httpContent- The HttpContent asByteBufHolder
-
isServerPushSupported
public boolean isServerPushSupported()
- Specified by:
isServerPushSupportedin interfaceio.micronaut.http.PushCapableHttpRequest<T>
-
serverPush
public io.micronaut.http.PushCapableHttpRequest<T> serverPush(@NonNull io.micronaut.http.HttpRequest<?> request)
- Specified by:
serverPushin interfaceio.micronaut.http.PushCapableHttpRequest<T>
-
initCharset
protected java.nio.charset.Charset initCharset(java.nio.charset.Charset characterEncoding)
- Specified by:
initCharsetin classio.micronaut.http.netty.AbstractNettyHttpRequest<T>
-
-