CS FundamentalsHardGATE CS · Product company CS fundamentals

An HTTP/1.1 server streams a response whose final size is unknown when it starts sending. How does the client know where the body ends on a persistent connection?

  1. A. The server closes the TCP connection after every response
  2. B. The client waits for a 2-second pause in the data
  3. C. The server sends Content-Length: 0 and then the body
  4. D. The server uses Transfer-Encoding: chunked, ending with a zero-length chunk

Correct answer: D. The server uses Transfer-Encoding: chunked, ending with a zero-length chunk

Without Content-Length, chunked encoding prefixes each chunk with its size and terminates with a 0-size chunk, so the connection can be reused. Closing the connection also delimits a body, but then it is no longer persistent.

More Computer Networks questions

Exams that ask this topic