You would likely need to do something like:

final OutputStream out = message.getContent(OutputStream.class);
CachedOutputStream cout = new CachedOutputStream() {
    public void close() {
         if (size() > 300) {
             throw new IOException();
         }
        writeTo(out);
   }
};
message.setContent(cout, OutputStream.class);

or similar.   You could probably do the size check by overriding the write 
methods and checking then to "fail faster".

Dan



On Sep 12, 2012, at 11:46 AM, shadowlaw <[email protected]> wrote:

> this solution seems to be working
> OutputStream os = message.getContent(OutputStream.class);
>        CacheAndWriteOutputStream cwos = new CacheAndWriteOutputStream(os);
>        cwos.setMaxSize(300L);
>        try {
>            cwos.writeCacheTo(os);
>            message.setContent(OutputStream.class, cwos);
>        } catch (Exception e) {
>            System.out.println("caught exception");
>            e.printStackTrace();
>        }
> 
> it raises exception when the size exceeds 300, but the buffered output
> stream is nevertheless send, how to make the process abort and send fault
> instead?
> 
> 
> 
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/extract-Http-Headers-tp5713851p5713866.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to