hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Truncated content-length delimited message bodies
Date Fri, 13 May 2011 10:20:57 GMT
On Fri, 2011-05-13 at 15:32 +0530, Asankha C. Perera wrote:
> Hi Oleg
> > I think I have a slightly less hacky work-around for the problem. How
> > about creating a custom version of ContentDecoderChannel that catches
> > ConnectionClosedException and re-throws it as a runtime exception of
> > some sort? This would enable your code to handle truncated messages and
> > would not require the hack to be applied to HttpCore? Would that work
> > for you?
> If this is possible, it will be fine. However it seems like this is hard 
> coded in NHttpConnectionBase.createContentDecoder() .. is there an easy 
> way I did not notice to register my own decoder?

What I was thinking of was something along the lines

public class ContentDecoderChannel implements ReadableByteChannel {

    private final ContentDecoder decoder;

    public ContentDecoderChannel(ContentDecoder decoder) {
        this.decoder = decoder;

    public int read(ByteBuffer dst) throws IOException {
        try {
            return decoder.read(dst);
        } catch (ConnectionClosedException ex) {
            throw new RuntimeException("Truncated entity");

    public void close() {}

    public boolean isOpen() {
        return true;


Would that work the problem around for you?


To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message