Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26264 > unrolled thread

How to get the size of the HTTPResponse

Started byKiran Bagga <kbagga@gmail.com>
First post2013-10-09 16:54 -0700
Last post2013-10-17 15:43 -0700
Articles 8 — 6 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  How to get the size of the HTTPResponse Kiran Bagga <kbagga@gmail.com> - 2013-10-09 16:54 -0700
    Re: How to get the size of the HTTPResponse markspace <markspace@nospam.nospam> - 2013-10-09 17:17 -0700
    Re: How to get the size of the HTTPResponse Arne Vajhøj <arne@vajhoej.dk> - 2013-10-09 22:48 -0400
      Re: How to get the size of the HTTPResponse Kiran Bagga <kbagga@gmail.com> - 2013-10-10 10:20 -0700
        Re: How to get the size of the HTTPResponse Robert Klemme <shortcutter@googlemail.com> - 2013-10-10 23:05 +0200
        Re: How to get the size of the HTTPResponse Arne Vajhøj <arne@vajhoej.dk> - 2013-10-10 22:59 -0400
          Re: How to get the size of the HTTPResponse Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-10-13 09:45 +0200
    Re: How to get the size of the HTTPResponse Roedy Green <see_website@mindprod.com.invalid> - 2013-10-17 15:43 -0700

#26264 — How to get the size of the HTTPResponse

FromKiran Bagga <kbagga@gmail.com>
Date2013-10-09 16:54 -0700
SubjectHow to get the size of the HTTPResponse
Message-ID<06aca5db-af01-4251-b5e4-ce24a677e7b5@googlegroups.com>
Hi


Maybe I am over thinking this or doing something dumb, But I cant seem to extract the right size of the HttpResponse object on the server side. I need it to log the number of response bytes. Any suggestions?? 

[toc] | [next] | [standalone]


#26265

Frommarkspace <markspace@nospam.nospam>
Date2013-10-09 17:17 -0700
Message-ID<l34rnn$j4f$1@dont-email.me>
In reply to#26264
On 10/9/2013 4:54 PM, Kiran Bagga wrote:
> Hi
>
>
> Maybe I am over thinking this or doing something dumb, But I cant
> seem to extract the right size of the HttpResponse object on the
> server side. I need it to log the number of response bytes. Any
> suggestions??
>


What have you tried?  Did you account for filters that may be modifying 
the stream after you count it?

Overall, I think I'd try my firewall first.  It seems to me that's a 
sure fire method of accounting for network traffic.  Programming comes 
second.

What's the need driving knowing what the byte output count?

[toc] | [prev] | [next] | [standalone]


#26268

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-10-09 22:48 -0400
Message-ID<5256158d$0$293$14726298@news.sunsite.dk>
In reply to#26264
On 10/9/2013 7:54 PM, Kiran Bagga wrote:
> Maybe I am over thinking this or doing something dumb, But I cant
> seem to extract the right size of the HttpResponse object on the
> server side. I need it to log the number of response bytes. Any
> suggestions??

Servlet filter?

Arne

[toc] | [prev] | [next] | [standalone]


#26293

FromKiran Bagga <kbagga@gmail.com>
Date2013-10-10 10:20 -0700
Message-ID<3281b0ef-b6d8-445b-adc6-36735aa934fc@googlegroups.com>
In reply to#26268
I am using servlet filters. The output body is stored in the OutputStream. I cant seem to find a way to extract the body from it and calculate the size. Any suggestions?

On Wednesday, October 9, 2013 7:48:45 PM UTC-7, Arne Vajhøj wrote:
> On 10/9/2013 7:54 PM, Kiran Bagga wrote:
> 
> > Maybe I am over thinking this or doing something dumb, But I cant
> 
> > seem to extract the right size of the HttpResponse object on the
> 
> > server side. I need it to log the number of response bytes. Any
> 
> > suggestions??
> 
> 
> 
> Servlet filter?
> 
> 
> 
> Arne

[toc] | [prev] | [next] | [standalone]


#26296

FromRobert Klemme <shortcutter@googlemail.com>
Date2013-10-10 23:05 +0200
Message-ID<bboj4iF2q26U1@mid.individual.net>
In reply to#26293
On 10.10.2013 19:20, Kiran Bagga wrote:
> I am using servlet filters. The output body is stored in the
> OutputStream. I cant seem to find a way to extract the body from it
> and calculate the size. Any suggestions?

You should be able to stack another OutputStream on the other one.  The 
stacked stream could then count bytes.  Still the problem Mark mentioned 
remains.

Cheers

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

[toc] | [prev] | [next] | [standalone]


#26300

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-10-10 22:59 -0400
Message-ID<5257697a$0$303$14726298@news.sunsite.dk>
In reply to#26293
On 10/10/2013 1:20 PM, Kiran Bagga wrote:
> On Wednesday, October 9, 2013 7:48:45 PM UTC-7, Arne Vajhøj wrote:
>> On 10/9/2013 7:54 PM, Kiran Bagga wrote:
>>> Maybe I am over thinking this or doing something dumb, But I cant
>>> seem to extract the right size of the HttpResponse object on the
>>> server side. I need it to log the number of response bytes. Any
>>> suggestions??
>>
>> Servlet filter?
 >
 > I am using servlet filters. The output body is stored in the
 > OutputStream. I cant seem to find a way to extract the body from it
 > and calculate the size. Any suggestions?

You make it use an ByteArrayOutputStream.

Google finds:

http://angelborroy.wordpress.com/2009/03/04/dump-request-and-response-using-javaxservletfilter/

I can try and create a simpler example if I find time for it.

Arne

[toc] | [prev] | [next] | [standalone]


#26318

FromDaniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Date2013-10-13 09:45 +0200
Message-ID<l3dj2i$st$1@dont-email.me>
In reply to#26300
On 2013-10-11 04:59, Arne Vajhøj allegedly wrote:
> On 10/10/2013 1:20 PM, Kiran Bagga wrote:
>> On Wednesday, October 9, 2013 7:48:45 PM UTC-7, Arne Vajhøj wrote:
>>> On 10/9/2013 7:54 PM, Kiran Bagga wrote:
>>>> Maybe I am over thinking this or doing something dumb, But I cant
>>>> seem to extract the right size of the HttpResponse object on the
>>>> server side. I need it to log the number of response bytes. Any
>>>> suggestions??
>>>
>>> Servlet filter?
>>
>> I am using servlet filters. The output body is stored in the
>> OutputStream. I cant seem to find a way to extract the body from it
>> and calculate the size. Any suggestions?
> 
> You make it use an ByteArrayOutputStream.
> 
> Google finds:
> 
> http://angelborroy.wordpress.com/2009/03/04/dump-request-and-response-using-javaxservletfilter/
> 
> 
> I can try and create a simpler example if I find time for it.

While it would work, counting how many bytes went through the wire does
not require dumping the response in a BAOS, and hence break the
streaming. A CountingOutputStream layer would be sufficient.

Note that if it's  only the size of the body that is of interest (as
opposed to the size of the body plus the header), then there likely
already is a component that computes that, to set the Content-Length
response header.

-- 
DF.

[toc] | [prev] | [next] | [standalone]


#26365

FromRoedy Green <see_website@mindprod.com.invalid>
Date2013-10-17 15:43 -0700
Message-ID<r0q0691o0gbd7cpiosfgif45ho6j68tpe8@4ax.com>
In reply to#26264
On Wed, 9 Oct 2013 16:54:08 -0700 (PDT), Kiran Bagga
<kbagga@gmail.com> wrote, quoted or indirectly quoted someone who said
:

>Maybe I am over thinking this or doing something dumb, 
But I cant seem to extract the right size of the HttpResponse object
on the server side. I need it to log the number of response bytes. Any
suggestions?? 

it is an optional field.  Sometimes the server does not even know it
to start. It just sends and sends until it runs out of bytes. You have
to keep could of how many you read.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Unlike many machines, computers require no water once they are
manufactured.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web