[
https://issues.apache.org/jira/browse/CAMEL-19251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17726367#comment-17726367
]
Dietrich Schulten commented on CAMEL-19251:
-------------------------------------------
The PR is taking form. In addition to providing a HttpProxyHandler, one also
has to suppress DNS resolution when an HttpProxyHandler is present. And the
SslHandler has to go *after* the HttpProxyHandler.
Suggestion: Let NettyProducer use a protected method
configureTcpClientBootstrap to set up the clientBootstrap. NettyHttpProducer
can override that and suppress the local DNS resolution.
In NettyProducer.openConnection():
{code:java}
if (isTcp()) {
// its okay to create a new bootstrap for each new channel
Bootstrap clientBootstrap = new Bootstrap();
if (configuration.isNativeTransport()) {
clientBootstrap.channel(EpollSocketChannel.class);
} else {
clientBootstrap.channel(NioSocketChannel.class);
}
clientBootstrap.group(getWorkerGroup());
configureTcpClientBootstrap(clientBootstrap); // <== new: call this
}
...
protected void configureTcpClientBootstrap(Bootstrap clientBootstrap) {
clientBootstrap.option(ChannelOption.SO_KEEPALIVE,
configuration.isKeepAlive());
clientBootstrap.option(ChannelOption.TCP_NODELAY,
configuration.isTcpNoDelay());
clientBootstrap.option(ChannelOption.SO_REUSEADDR,
configuration.isReuseAddress());
clientBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
configuration.getConnectTimeout());
}{code}
In NettyHttpProducer we tell the client bootstrap not to attempt local DNS
resolution if an HttpProxy is present:
{code:java}
@Override
protected void configureTcpClientBootstrap(Bootstrap clientBootstrap) {
super.configureTcpClientBootstrap(clientBootstrap);
NettyHttpConfiguration configuration = getConfiguration();
if (configuration.isUseHttpProxy()) {
clientBootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
}
}{code}
How does that sound? I have running code based upon 3.20.5-SNAPSHOT. I'll push
the code to my fork and create a PR. Probably, I would have to duplicate the
code on the main branch for the 4.0.0 version (or cherry-pick it there), right?
> Support Netty Http Producer behind HTTP Proxy
> ---------------------------------------------
>
> Key: CAMEL-19251
> URL: https://issues.apache.org/jira/browse/CAMEL-19251
> Project: Camel
> Issue Type: New Feature
> Components: camel-netty-http
> Reporter: Dietrich Schulten
> Priority: Major
>
> I need to implement a streaming webdav proxy. Netty would be a pretty natural
> choice, but I need to reach the target system through a corporate proxy.
> Currently, the NettyHttpProducer can't do that. It appears one needs to add
> an HttpProxyHandler for this. Can we make the Netty Producer aware of an Http
> Proxy?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)