B K wrote:
As the response body is wrapped by GZIPInputStream I don't believe I would be able to do this for a true indication of bw, please correct me if Im wrong.

See what Roland wrote about a filtered stream that counts the bytes in
all read and skip methods.

Bad idea!
You try to mix binary data with character data without any care for character encodings. What method do you use to append data to the buffer?
I gave this a go, with the understanding it may require a permanent solution later, so i coded the following to see if it works

ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));

Streams are for binary data, Readers are for character data.
You are still mixing the two.

If you use an InputStreamReader then specify the character encoding
you want for the conversion of bytes to characters.

String line = br.readLine();

reading lines means that you are reading characters.

...However I get exactly the same result, I thought this is what you meant to try? If not please excuse my ignorance.

You really have to read up on what streams and readers are for.

Using a FilterInputStream as Roland suggests is the right way, but
if you do not want that you can try something like this:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = method.getResponseBodyAsStream();
byte[] buf = new byte[1024];
int read = 0;
while ((read = is.read(buf)) > -1)
    baos.write(buf, 0, read);

/* use baos.array for gzip input.. */

I do not think that you need to use a BufferedInputStream since
the code already does read(byte[]), but I am not sure, add the
BufferedInputStream if you need it.

/robo


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to