This is our old Q&A Site. Please post any new questions and answers at

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

accept rate: 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.

permanent link

answered 26 Sep '12, 01:19

SYN-bit's gravatar image

SYN-bit ♦♦
accept rate: 20%

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

(27 Sep '12, 21:26) yogeshdg
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 25 Sep '12, 20:28

question was seen: 15,345 times

last updated: 27 Sep '12, 21:26

p​o​w​e​r​e​d by O​S​Q​A