DefaultProxyConnectProtocol extends AbstractProxyProtocol<ProxyConnectProtocolParser> implements ProxyConnectProtocol { @Override public void recordForwardFor(InetSocketAddress address) { ProxyForwardForParser forwardForParser = (ProxyForwardForParser) parser.getProxyOptionParser(PROXY_OPTION.FORWARD_FOR); if(forwardForParser == null) { forwardForParser = new ForwardForOptionParser(); parser.addProxyOptionParser(forwardForParser); } forwardForParser.append(address); } DefaultProxyConnectProtocol(ProxyConnectProtocolParser parser); @Override List<ProxyEndpoint> nextEndpoints(); @Override void recordForwardFor(InetSocketAddress address); @Override String getForwardFor(); @Override void setContent(String content); @Override String getContent(); @Override String getRouteInfo(); @Override String getFinalStation(); @Override String getSource(); @Override boolean isCompressed(); @Override CompressAlgorithm getCompressAlgorithm(); @Override void removeCompressOptionIfExist(); @Override void addCompression(CompressAlgorithm algorithm); @Override String toString();  }
@Test public void recordForwardFor() { parser = new DefaultProxyConnectProtocolParser(); protocol = (DefaultProxyConnectProtocol) parser.read("PROXY ROUTE TCP: InetSocketAddress address = new InetSocketAddress("127.0.0.1", randomPort()); protocol.recordForwardFor(address); logger.info("{}", protocol.getForwardFor()); Assert.assertEquals(String.format("FORWARD_FOR %s:%d", address.getAddress().getHostAddress(), address.getPort()), protocol.getForwardFor()); }