Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to configure my own ChannelPipeline #88

Closed
charlesk40 opened this issue Apr 19, 2012 · 9 comments
Closed

Not able to configure my own ChannelPipeline #88

charlesk40 opened this issue Apr 19, 2012 · 9 comments

Comments

@charlesk40
Copy link

I want to override the HttpContentDecompressor which I would like to use it for decoding gzip file types. But since some response come in without the proper contentEncoding header, HttpContentDecompressor is ignored. Can we make it so that we can construct custom handlers to the ChannelPipeline?

plainBootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        /* @Override */
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = pipeline();

            pipeline.addLast(HTTP_HANDLER, new HttpClientCodec());

            if (config.getRequestCompressionLevel() > 0) {
                pipeline.addLast("deflater", new HttpContentCompressor(config.getRequestCompressionLevel()));
            }

            if (config.isCompressionEnabled()) {
                pipeline.addLast("inflater", new HttpContentDecompressor());
            }
            pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
            pipeline.addLast("httpProcessor", NettyAsyncHttpProvider.this);
            return pipeline;
        }
    });
@jfarcand
Copy link
Contributor

Mark the issue as an enhancements. This could be done using the NettyAsyncHttpProviderConfig allowing the use of customized Pipeline

@jfarcand
Copy link
Contributor

This has been fixed and available now by #205

@slandelle
Copy link
Contributor

Backport to 1.7.x?

@jfarcand
Copy link
Contributor

Not necessary IMO.

@selangley
Copy link

I would re-open this issue if I could.

The current implementation in 1.9.33 has taken away the ability to customize your own Channel Pipeline. The code in question has been moved into the method:

configureBootstraps(NettyRequestSender requestSender, AtomicBoolean closed) 

of class com.ning.http.client.providers.netty.channel.ChannelManager

where many of the variables you would want to access are private.

@slandelle
Copy link
Contributor

With all due respect to Jean-François, I think this move was a wrong one. Allowing for extensibility this way is no less than making it easier for people for fork without ever contributing back. That's not how open-source is supposed to work!

If you need to customize the pipeline, there's the channel initializers in the Netty config. Otherwise, state your use case and let's discuss about it so we can bring a solution that can benefit the whole project, not just you alone.

@selangley
Copy link

Your comment pointed me in the right direction. I had a similar use case to the original submitter. I wanted to not automatically decompress gzip files. The below, written in Groovy, worked for me.

Perhaps the real issue is that the documentation is scarce. I was attempting to use the approach talked about in this ticket, which no longer works.

myNettyProviderConfig.setHttpAdditionalPipelineInitializer(new NettyPipelineInflaterRemover())

public static class NettyPipelineInflaterRemover extends com.ning.http.client.providers.netty.NettyAsyncHttpProviderConfig.AdditionalPipelineInitializer {
    void    initPipeline(org.jboss.netty.channel.ChannelPipeline pipeline) {
        pipeline.remove(com.ning.http.client.providers.netty.channel.ChannelManager.INFLATER_HANDLER)
    }
}

@selangley
Copy link

The new way to do it was implemented here: #717

@slandelle
Copy link
Contributor

Perhaps the real issue is that the documentation is scarce.

It's not like I'm getting any help here, nor that I make a living with this project... :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants