Class HttpsRelayServiceHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
google.registry.proxy.handler.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 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 
    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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final FrontendMetrics
     
    protected static final com.google.common.collect.ImmutableSet<Class<? extends Exception>>
     
    protected static final com.google.common.collect.ImmutableSet<Class<? extends Exception>>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf byteBuf, List<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, Throwable cause)
    Terminates connection upon inbound exception.
    void
    write(io.netty.channel.ChannelHandlerContext ctx, 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 Details

    • NON_FATAL_INBOUND_EXCEPTIONS

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

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

      protected final FrontendMetrics metrics
  • Method Details

    • 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, List<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 Exception
      Specified by:
      encode in class io.netty.handler.codec.ByteToMessageCodec<io.netty.handler.codec.http.FullHttpResponse>
      Throws:
      Exception
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, 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, Object msg, io.netty.channel.ChannelPromise promise) throws 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:
      Exception