Class 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 Netty HttpRequest instance.
    Since:
    1.0
    • Field Summary

      • Fields inherited from class io.micronaut.http.netty.AbstractNettyHttpRequest

        conversionService, HTTP2_SCHEME, httpMethod, httpMethodName, nettyRequest, STREAM_ID, uri
      • Fields inherited from interface io.micronaut.http.HttpRequest

        SCHEME_HTTP, SCHEME_HTTPS
    • 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
      void addContent​(io.netty.buffer.ByteBufHolder httpContent)  
      protected java.lang.Object buildBody()  
      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.ChannelHandlerContext getChannelHandlerContext()  
      io.micronaut.http.cookie.Cookies getCookies()  
      io.micronaut.http.HttpHeaders getHeaders()  
      io.micronaut.web.router.RouteMatch<?> getMatchedRoute()  
      io.netty.handler.codec.http.HttpRequest getNativeRequest()  
      java.net.InetSocketAddress getRemoteAddress()  
      java.net.InetSocketAddress getServerAddress()  
      java.lang.String getServerName()  
      protected java.nio.charset.Charset initCharset​(java.nio.charset.Charset characterEncoding)  
      boolean isSecure()  
      boolean isServerPushSupported()  
      io.micronaut.http.MutableHttpRequest<T> mutate()  
      void prepareHttp2ResponseIfNecessary​(io.netty.handler.codec.http.HttpResponse finalResponse)
      Prepares a response based on this HTTP/2 request if HTTP/2 is enabled.
      void release()
      Release and cleanup resources.
      protected void releaseIfNecessary​(java.lang.Object value)  
      io.micronaut.http.PushCapableHttpRequest<T> serverPush​(io.micronaut.http.HttpRequest<?> request)  
      void setBody​(T body)
      Sets the body.
      java.lang.String toString()  
      • 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 io.netty.util.DefaultAttributeMap

        attr, hasAttr
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface io.micronaut.core.attr.AttributeHolder

        getAttribute
      • Methods inherited from interface io.micronaut.http.HttpMessage

        getCharacterEncoding, getContentLength, getContentType
      • Methods inherited from interface io.micronaut.http.HttpRequest

        accept, getCertificate, getHttpVersion, getLocale, getMethod, getMethodName, getParameters, getPath, getUri, getUserPrincipal, getUserPrincipal, setAttribute
      • Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder

        removeAttribute
    • 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 - The HttpRequest
        ctx - The ChannelHandlerContext
        environment - The Environment
        serverConfiguration - The HttpServerConfiguration
    • 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, never null
      • mutate

        public io.micronaut.http.MutableHttpRequest<T> mutate()
        Specified by:
        mutate in interface io.micronaut.http.HttpRequest<T>
      • getAttribute

        @NonNull
        public java.util.Optional<java.lang.Object> getAttribute​(java.lang.CharSequence name)
        Specified by:
        getAttribute in interface io.micronaut.core.attr.AttributeHolder
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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:
        getCookies in interface io.micronaut.http.HttpRequest<T>
      • getRemoteAddress

        public java.net.InetSocketAddress getRemoteAddress()
        Specified by:
        getRemoteAddress in interface io.micronaut.http.HttpRequest<T>
      • getServerAddress

        public java.net.InetSocketAddress getServerAddress()
        Specified by:
        getServerAddress in interface io.micronaut.http.HttpRequest<T>
      • getServerName

        public java.lang.String getServerName()
        Specified by:
        getServerName in interface io.micronaut.http.HttpRequest<T>
      • isSecure

        public boolean isSecure()
        Specified by:
        isSecure in interface io.micronaut.http.HttpRequest<T>
      • getHeaders

        public io.micronaut.http.HttpHeaders getHeaders()
        Specified by:
        getHeaders in interface io.micronaut.http.HttpMessage<T>
      • getAttributes

        public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
        Specified by:
        getAttributes in interface io.micronaut.core.attr.AttributeHolder
        Specified by:
        getAttributes in interface io.micronaut.http.HttpMessage<T>
        Specified by:
        getAttributes in interface io.micronaut.core.attr.MutableAttributeHolder
      • getBody

        public java.util.Optional<T> getBody()
        Specified by:
        getBody in interface io.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:
        getBody in interface io.micronaut.http.HttpMessage<T>
      • getBody

        public <T1> java.util.Optional<T1> getBody​(io.micronaut.core.type.Argument<T1> type)
        Specified by:
        getBody in interface io.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 as ByteBufHolder
      • isServerPushSupported

        public boolean isServerPushSupported()
        Specified by:
        isServerPushSupported in interface io.micronaut.http.PushCapableHttpRequest<T>
      • serverPush

        public io.micronaut.http.PushCapableHttpRequest<T> serverPush​(@NonNull
                                                                      io.micronaut.http.HttpRequest<?> request)
        Specified by:
        serverPush in interface io.micronaut.http.PushCapableHttpRequest<T>
      • initCharset

        protected java.nio.charset.Charset initCharset​(java.nio.charset.Charset characterEncoding)
        Specified by:
        initCharset in class io.micronaut.http.netty.AbstractNettyHttpRequest<T>