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?
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]