cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: How to get in/out message length in the interceptors?
Date Tue, 10 Jun 2014 19:30:54 GMT

On Jun 10, 2014, at 10:27 AM, Przemyslaw Bielicki <pbielicki@gmail.com> wrote:

> I need to know the input and output message size in my interceptors.
> 
> I assume that "Content-Length" is not set in the request i.e.
> (Transfer-Encoding = chunked), so I cannot take the in length from the HTTP
> header - it must be really "computed".
> 
> Additional difficulty is that I don't want to serialize incoming and
> outgoing messages toString() as it will be a performance issue.
> 
> Is there any way to get these sizes from the Input/OutputStream? Is there a
> way to inject my custom stream wrappers that will be counting number of
> bytes read/written?

You would need to write an interceptor that would live fairly early in the interceptor chain
that would do something like:

InputStream in = message.getContent(InputStream.class);
in = new MyLengthRecordingStream(in);
message.setContent(InputSteam.class, in);

The rest of the processing would then use your input stream and at the end of all the processing,
you would have the length.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
View raw message