HTTP is a framing protocol for dealing with a TCP/IP stream

A web server is a TCP/IP server which receives requests from web browsers which are TCP/IP clients.

Like any TCP/IP protocol since TCP/IP is stream based we have to solve this problem.

How can we tell the beginning and end of an request for a document and a response to that request?

i.e. HTTP is a framing protocol. The most common simple way HTTP works to frame messages is that it has a series of name value headers which are terminated with newline sequence \r\n. The end of the headers have \r\n\r\n.

There is often a header with the name Content-Length: which has the number of bytes of the content encoded in decimal.

It’s not the only way the framing can be implemented but it is a simple way.