Class HttpProxyHandler

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler

public final class HttpProxyHandler extends ProxyHandler
Handler that establishes a blind forwarding proxy tunnel using HTTP/1.1 CONNECT request. It can be used to establish plaintext or secure tunnels.

HTTP users who need to connect to a message-forwarding HTTP proxy agent instead of a tunneling proxy should not use this handler.

  • Field Details

    • PROTOCOL

      private static final java.lang.String PROTOCOL
      See Also:
    • AUTH_BASIC

      private static final java.lang.String AUTH_BASIC
      See Also:
    • codecWrapper

      private final HttpProxyHandler.HttpClientCodecWrapper codecWrapper
    • username

      private final java.lang.String username
    • password

      private final java.lang.String password
    • authorization

      private final java.lang.CharSequence authorization
    • outboundHeaders

      private final HttpHeaders outboundHeaders
    • ignoreDefaultPortsInConnectHostHeader

      private final boolean ignoreDefaultPortsInConnectHostHeader
    • validateInitialHeaders

      private final boolean validateInitialHeaders
    • status

      private HttpResponseStatus status
    • inboundHeaders

      private HttpHeaders inboundHeaders
  • Constructor Details

    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader, boolean validateInitialHeaders)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader)
    • HttpProxyHandler

      public HttpProxyHandler(java.net.SocketAddress proxyAddress, java.lang.String username, java.lang.String password, HttpHeaders headers, boolean ignoreDefaultPortsInConnectHostHeader, boolean validateInitialHeaders)
  • Method Details

    • protocol

      public java.lang.String protocol()
      Description copied from class: ProxyHandler
      Returns the name of the proxy protocol in use.
      Specified by:
      protocol in class ProxyHandler
    • authScheme

      public java.lang.String authScheme()
      Description copied from class: ProxyHandler
      Returns the name of the authentication scheme in use.
      Specified by:
      authScheme in class ProxyHandler
    • username

      public java.lang.String username()
    • password

      public java.lang.String password()
    • addCodec

      protected void addCodec(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Adds the codec handlers required to communicate with the proxy server.
      Specified by:
      addCodec in class ProxyHandler
      Throws:
      java.lang.Exception
    • removeEncoder

      protected void removeEncoder(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Removes the encoders added in ProxyHandler.addCodec(ChannelHandlerContext).
      Specified by:
      removeEncoder in class ProxyHandler
      Throws:
      java.lang.Exception
    • removeDecoder

      protected void removeDecoder(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Removes the decoders added in ProxyHandler.addCodec(ChannelHandlerContext).
      Specified by:
      removeDecoder in class ProxyHandler
      Throws:
      java.lang.Exception
    • newInitialMessage

      protected java.lang.Object newInitialMessage(ChannelHandlerContext ctx) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Returns a new message that is sent at first time when the connection to the proxy server has been established.
      Specified by:
      newInitialMessage in class ProxyHandler
      Returns:
      the initial message, or null if the proxy server is expected to send the first message instead
      Throws:
      java.lang.Exception
    • handleResponse

      protected boolean handleResponse(ChannelHandlerContext ctx, java.lang.Object response) throws java.lang.Exception
      Description copied from class: ProxyHandler
      Handles the message received from the proxy server.
      Specified by:
      handleResponse in class ProxyHandler
      Returns:
      true if the connection to the destination has been established, false if the connection to the destination has not been established and more messages are expected from the proxy server
      Throws:
      java.lang.Exception