Class HttpsRelayServiceHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler
    Direct Known Subclasses:
    EppServiceHandler, WhoisServiceHandler

    public abstract class HttpsRelayServiceHandler
    extends io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
    Handler that relays a single (framed) ByteBuf message to an HTTPS server.

    This handler reads in a ByteBuf, converts it to an FullHttpRequest, and passes it to the channelRead method of the next inbound handler the channel pipeline, which is usually a RelayHandler<FullHttpRequest>. The relay handler writes the request to the relay channel, which is connected to an HTTPS endpoint. After the relay channel receives a FullHttpResponse back, its own relay handler writes the response back to this channel, which is the relay channel of the relay channel. This handler then handles write request by encoding the FullHttpResponse to a plain ByteBuf, and pass it down to the write method of the next outbound handler in the channel pipeline, which eventually writes the response bytes to the remote peer of this channel.

    This handler is session aware and will store all the session cookies that the are contained in the HTTP response headers, which are added back to headers of subsequent HTTP requests.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  HttpsRelayServiceHandler.NonOkHttpResponseException
      Exception thrown when the response status from GAE is not 200.
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void decode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf byteBuf, java.util.List<java.lang.Object> out)  
      protected io.netty.handler.codec.http.FullHttpRequest decodeFullHttpRequest​(io.netty.buffer.ByteBuf byteBuf)
      Construct the FullHttpRequest.
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpResponse response, io.netty.buffer.ByteBuf byteBuf)  
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
      Terminates connection upon inbound exception.
      void write​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise)
      Terminates connection upon outbound exception.
      • Methods inherited from class io.netty.handler.codec.ByteToMessageCodec

        acceptOutboundMessage, channelInactive, channelRead, channelReadComplete, decodeLast, handlerAdded, handlerRemoved
      • Methods inherited from class io.netty.channel.ChannelDuplexHandler

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NON_FATAL_INBOUND_EXCEPTIONS

        protected static final com.google.common.collect.ImmutableSet<java.lang.Class<? extends java.lang.Exception>> NON_FATAL_INBOUND_EXCEPTIONS
      • NON_FATAL_OUTBOUND_EXCEPTIONS

        protected static final com.google.common.collect.ImmutableSet<java.lang.Class<? extends java.lang.Exception>> NON_FATAL_OUTBOUND_EXCEPTIONS
    • Method Detail

      • decodeFullHttpRequest

        protected io.netty.handler.codec.http.FullHttpRequest decodeFullHttpRequest​(io.netty.buffer.ByteBuf byteBuf)
        Construct the FullHttpRequest.

        This default method creates a bare-bone FullHttpRequest that may need to be modified, e. g. adding headers specific for each protocol.

        Parameters:
        byteBuf - inbound message.
      • decode

        protected void decode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf byteBuf,
                              java.util.List<java.lang.Object> out)
        Specified by:
        decode in class io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.handler.codec.http.FullHttpResponse response,
                              io.netty.buffer.ByteBuf byteBuf)
                       throws java.lang.Exception
        Specified by:
        encode in class io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
        Throws:
        java.lang.Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    java.lang.Throwable cause)
        Terminates connection upon inbound exception.
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      • write

        public void write​(io.netty.channel.ChannelHandlerContext ctx,
                          java.lang.Object msg,
                          io.netty.channel.ChannelPromise promise)
                   throws java.lang.Exception
        Terminates connection upon outbound exception.
        Specified by:
        write in interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        write in class io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
        Throws:
        java.lang.Exception