Hi,

For the big message, to get it size you have to break the stream way to read 
the message anyway(which means lose some performance).
So you can 

1.write a customer interceptor(Phase.RECEIVE) to make the stream re-readable, 
some code like

public void handleMessage(Message message) throws Fault {
        InputStream is = message.getContent(InputStream.class);
        if (is != null) {
            CachedOutputStream bos = new CachedOutputStream();
            try {
                IOUtils.copy(is, bos);

                bos.flush();
                is.close();
                message.setContent(InputStream.class, bos.getInputStream());
                bos.close();
                long messageSize = bos.size(); // here you can get the message 
size
                
            } catch (IOException e) {
                throw new Fault(e);
            }
        }

    }

or 
2. disable CXF chunk[1] so that you can get Content-Length from the http header.

[1]http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html

Freeman

-------------
Freeman Fang

FuseSource
Email:[email protected]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-9-12, at 下午8:09, shadowlaw wrote:

> actually, i'm using code like this but the return result is empty. My problem
> is that i need to calculate the size of the message response before sending
> it because we have a constraint on the size of the messages, so i thought i
> could get the information from the header without any success. If any other
> alternative to my problem, please let me know.
> 
> 
> 
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/extract-Http-Headers-tp5713851p5713853.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to