This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

http content length calculation

0

Can anyone explain how do I calculate the content length in a http response? I do see the content length header with some value in the server response but would like to validate it. Is there any manual way?

I tried adding the tcp lengths of all previous packets including the http response with the status code but guess I need to subtract http header from the last packet. Please help!

asked 25 Sep '12, 20:28

yogeshdg's gravatar image

yogeshdg
1111
accept rate: 0%


One Answer:

0

The HTTP header ends with an empty line ("CR/LF/CR/LF", 0d0a0d0a). The content of the HTTP body starts at the first byte after the "CR/LF/CR/LF". So count the bytes from that point. If all is well, the byte pointed to by the content length header should indeed be the last byte of the object being served by the HTTP server.

answered 26 Sep '12, 01:19

SYN-bit's gravatar image

SYN-bit ♦♦
17.1k957245
accept rate: 20%

Thanks. That makes sense. Appreciate your help. I didn't notice this:)(

(27 Sep '12, 21:26) yogeshdg