Chunked http decoding in java?

Use a fullworthy HTTP client like Apache HttpComponents Client or just the Java SE provided java.net. URLConnection ( mini tutorial here ). Both handles it fully transparently and gives you a "normal InputStream back.

HttpClient in turn also comes with a ChunkedInputStream which you just have to decorate your InputStream with If you really insist in homegrowing a library for this, then I'd suggest to create a class like ChunkedInputStream extends InputStream and write logic accordingly. You can find more detail how to parse it in this Wikipedia article.

Use a fullworthy HTTP client like Apache HttpComponents Client or just the Java SE provided java.net. URLConnection (mini tutorial here). Both handles it fully transparently and gives you a "normal" InputStream back.

HttpClient in turn also comes with a ChunkedInputStream which you just have to decorate your InputStream with. If you really insist in homegrowing a library for this, then I'd suggest to create a class like ChunkedInputStream extends InputStream and write logic accordingly. You can find more detail how to parse it in this Wikipedia article.

Actually I make offline http decoding and I have just header and body of http packet. And I will decode the packet. But I need an api that gets header and body and gives me decoded data.Is there so api?

– CodingForever Sep 15 '10 at 13:38 The Wikipedia article contains detail how a chunk look like. You can basically just split on CRLF (\r\n). It are the bytes 10 and 13.

The first part is then the header which represents the chunk length in hex. The second part is then the chunk data itself. You just collect and concatenate all those chunks.

The ChunkedInputStream does exactly that. – BalusC Sep 15 '10 at 13:46 because your answer is right. – CodingForever Sep 15 '10 at 14:32 Sorry , there are two ChunkedInputStream class first: jigsaw.

W3. Org/Doc/Programmer/api/org/w3c/www/http/… second: hc.apache.Org/httpclient-3. X/apidocs/org/apache/commons/… Which one is right for this?

And Do you have any information about how to use ChunkedInputStream? – CodingForever Sep 16 '10 at 8:20 The ChunkedInputStream part in my answer is clickable (as all other blueish parts). It's an InputStream, you can just decorate another InputStream with it.

E.g. InputStream input = new ChunkedInputStream(originalInput);. – BalusC Sep 16 '10 at 11:12.

Apache HttpComponents Oh, and if we are talking about the client side, HttpUrlConnection does this as well.

I will offline http decoding( already captured packets ) and I have just a header and a body. So I need an api that gets just header and body and gives me decoded data. Is there any api like this?

– CodingForever Sep 15 '10 at 13:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions