• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading chunked data from socket.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In http response header I am seeing "Transfer-Encoding: chunked". Each chunk comes with a header indicator on the length of chunk. While reading response from socket and appending it to string buffer, the chunk header is also getting in as part of response. How to avoid this unwanted part (Chunk length) from getting to my final response string.
Here is the code that I use to read response from socket.

byte[] buf = new byte[1024];
while ((i = in.read(buf)) > -1) {
String s = new String(buf, 0, i);
outputBuffer.append(s);
}
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this out.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.4.6
reply
    Bookmark Topic Watch Topic
  • New Topic