Home / Class/ HttpProxyHandler Class — netty Architecture

HttpProxyHandler Class — netty Architecture

Architecture documentation for the HttpProxyHandler class in HttpProxyHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9f67123e_d153_cb48_a674_901255ce7066["HttpProxyHandler"]
  39b60d5f_2d6d_6316_a4f9_8bff945ed606["HttpProxyHandler.java"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|defined in| 39b60d5f_2d6d_6316_a4f9_8bff945ed606
  826fa5b3_774f_2c5e_972e_9e1f79b3bbfc["HttpProxyHandler()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| 826fa5b3_774f_2c5e_972e_9e1f79b3bbfc
  b2c8f05b_4d22_a5cb_b923_b0f6c8896a08["String()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| b2c8f05b_4d22_a5cb_b923_b0f6c8896a08
  a7b76ea9_4e59_c8c9_da2d_74d63b021542["addCodec()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| a7b76ea9_4e59_c8c9_da2d_74d63b021542
  0a585cd9_2b66_14ad_f64b_2f3cfc1e30a2["removeEncoder()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| 0a585cd9_2b66_14ad_f64b_2f3cfc1e30a2
  79c4164f_8904_4434_6ae9_4f3f3429554d["removeDecoder()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| 79c4164f_8904_4434_6ae9_4f3f3429554d
  1f1f47a3_9a35_e392_13e3_6356ae8f2da8["Object()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| 1f1f47a3_9a35_e392_13e3_6356ae8f2da8
  030cbe3b_a8fe_f70a_8682_b62d05d3b14c["handleResponse()"]
  9f67123e_d153_cb48_a674_901255ce7066 -->|method| 030cbe3b_a8fe_f70a_8682_b62d05d3b14c

Relationship Graph

Source Code

handler-proxy/src/main/java/io/netty/handler/proxy/HttpProxyHandler.java lines 56–344

public final class HttpProxyHandler extends ProxyHandler {

    private static final String PROTOCOL = "http";
    private static final String AUTH_BASIC = "basic";

    // Wrapper for the HttpClientCodec to prevent it to be removed by other handlers by mistake (for example the
    // WebSocket*Handshaker.
    //
    // See:
    // - https://github.com/netty/netty/issues/5201
    // - https://github.com/netty/netty/issues/5070
    private final HttpClientCodecWrapper codecWrapper = new HttpClientCodecWrapper();
    private final String username;
    private final String password;
    private final CharSequence authorization;
    private final HttpHeaders outboundHeaders;
    private final boolean ignoreDefaultPortsInConnectHostHeader;
    private HttpResponseStatus status;
    private HttpHeaders inboundHeaders;

    public HttpProxyHandler(SocketAddress proxyAddress) {
        this(proxyAddress, null);
    }

    public HttpProxyHandler(SocketAddress proxyAddress, HttpHeaders headers) {
        this(proxyAddress, headers, false);
    }

    public HttpProxyHandler(SocketAddress proxyAddress,
                            HttpHeaders headers,
                            boolean ignoreDefaultPortsInConnectHostHeader) {
        super(proxyAddress);
        username = null;
        password = null;
        authorization = null;
        this.outboundHeaders = headers;
        this.ignoreDefaultPortsInConnectHostHeader = ignoreDefaultPortsInConnectHostHeader;
    }

    public HttpProxyHandler(SocketAddress proxyAddress, String username, String password) {
        this(proxyAddress, username, password, null);
    }

    public HttpProxyHandler(SocketAddress proxyAddress, String username, String password,
                            HttpHeaders headers) {
        this(proxyAddress, username, password, headers, false);
    }

    public HttpProxyHandler(SocketAddress proxyAddress,
                            String username,
                            String password,
                            HttpHeaders headers,
                            boolean ignoreDefaultPortsInConnectHostHeader) {
        super(proxyAddress);
        this.username = ObjectUtil.checkNotNull(username, "username");
        this.password = ObjectUtil.checkNotNull(password, "password");

        ByteBuf authz = Unpooled.copiedBuffer(username + ':' + password, CharsetUtil.UTF_8);
        ByteBuf authzBase64;
        try {
            authzBase64 = Base64.encode(authz, false);
        } finally {
            authz.release();
        }
        try {
            authorization = new AsciiString("Basic " + authzBase64.toString(CharsetUtil.US_ASCII));
        } finally {
            authzBase64.release();
        }

        this.outboundHeaders = headers;
        this.ignoreDefaultPortsInConnectHostHeader = ignoreDefaultPortsInConnectHostHeader;
    }

    @Override
    public String protocol() {
        return PROTOCOL;
    }

    @Override
    public String authScheme() {

Frequently Asked Questions

What is the HttpProxyHandler class?
HttpProxyHandler is a class in the netty codebase, defined in handler-proxy/src/main/java/io/netty/handler/proxy/HttpProxyHandler.java.
Where is HttpProxyHandler defined?
HttpProxyHandler is defined in handler-proxy/src/main/java/io/netty/handler/proxy/HttpProxyHandler.java at line 56.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free