Making the switch in html page reader from header info to gzip main content

S

steven

Okay, you have this line in the code to begin with
InputStream socketsInputStream = socket.getInputStream();


If you read off the html stream of a web page, and it utilizes gzip
encoding for the main data it server in the html page, then how do you
easily funnel the rest of the sockets data into :

BufferedReader reader = new BufferedReader(
new InputStreamReader(
new GZIPInputStream(
new FileInputStream( socketsInputStream ) ) ) );

when the socketsInputStream originally was fueling the
BufferedReader d = new BufferedReader(new
InputStreamReader(socketsInputStream),1); to get the header info from
the html server that says.

I gave it size 1 in hopes it would not peel off any more stream past
the lone \r\n that separates the html header from the data.
Problem is that the implementation of the InputStreamReader may use a
buffer that is larger than 1, so some unspecified amount of the data
after the header may have been lost from the sockets input stream.

So , what is the easy way to read the header , then read the gziped
data of the html page's stream.

Reason I ask is that I get a :
java.io.IOException: Not in GZIP format
error when I try to switch the socketsInputStream to the gzipped
enabled BufferedReader.

Make sense?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top