public static HttpCarbonMessage createInboundReqCarbonMsg ( HttpRequest httpRequestHeaders , ChannelHandlerContext ctx , SourceHandler sourceHandler ) { HttpCarbonMessage inboundRequestMsg = new HttpCarbonRequest ( httpRequestHeaders , new DefaultListener ( ctx ) ) ; inboundRequestMsg . setProperty ( Constants . POOLED_BYTE_BUFFER_FACTORY , new PooledDataStreamerFactory ( ctx . alloc ( ) ) ) ; inboundRequestMsg . setProperty ( Constants . CHNL_HNDLR_CTX , ctx ) ; inboundRequestMsg . setProperty ( Constants . SRC_HANDLER , sourceHandler ) ; HttpVersion protocolVersion = httpRequestHeaders . protocolVersion ( ) ; inboundRequestMsg . setProperty ( Constants . HTTP_VERSION , protocolVersion . majorVersion ( ) + "." + protocolVersion . minorVersion ( ) ) ; inboundRequestMsg . setProperty ( Constants . HTTP_METHOD , httpRequestHeaders . method ( ) . name ( ) ) ; InetSocketAddress localAddress = null ; //This check was added because in case of netty embedded channel, this could be of type 'EmbeddedSocketAddress'. if ( ctx . channel ( ) . localAddress ( ) instanceof InetSocketAddress ) { localAddress = ( InetSocketAddress ) ctx . channel ( ) . localAddress ( ) ; } inboundRequestMsg . setProperty ( Constants . LISTENER_PORT , localAddress != null ? localAddress . getPort ( ) : null ) ; inboundRequestMsg . setProperty ( Constants . LISTENER_INTERFACE_ID , sourceHandler . getInterfaceId ( ) ) ; inboundRequestMsg . setProperty ( Constants . PROTOCOL , Constants . HTTP_SCHEME ) ; boolean isSecuredConnection = false ; if ( ctx . channel ( ) . pipeline ( ) . get ( Constants . SSL_HANDLER ) != null ) { isSecuredConnection = true ; } inboundRequestMsg . setProperty ( Constants . IS_SECURED_CONNECTION , isSecuredConnection ) ; inboundRequestMsg . setProperty ( Constants . LOCAL_ADDRESS , ctx . channel ( ) . localAddress ( ) ) ; inboundRequestMsg . setProperty ( Constants . REMOTE_ADDRESS , sourceHandler . getRemoteAddress ( ) ) ; inboundRequestMsg . setProperty ( Constants . REQUEST_URL , httpRequestHeaders . uri ( ) ) ; inboundRequestMsg . setProperty ( Constants . TO , httpRequestHeaders . uri ( ) ) ; inboundRequestMsg . setProperty ( MUTUAL_SSL_HANDSHAKE_RESULT , ctx . channel ( ) . attr ( Constants . MUTUAL_SSL_RESULT_ATTRIBUTE ) . get ( ) ) ; return inboundRequestMsg ; }
Create a HttpCarbonMessage using the netty inbound http request .