title: Detect end of HTTP request body
body: <p>I'm playing around with writing my own HTTP client and server and want to have the client include an optional body in the request. On the server side I want to read the entire body before sending the HTTP response. My question is on the server how do I know that I've read the entire body?</p>
  
  <p>Even though in this case I control both the client and server, I'm looking for a "standard" approach. However, since Content-Length is optional I want a method that doesn't require it. If the client closes the connection, it is easy to read all available data, however the client needs to keep the connection open to wait for a response, so this method doesn't work.</p>
  
  <p>All that I can think I'm left with is having knowledge of the format of the body and detecting a terminator (eg. <code>&lt;/HTML&gt;</code>). Ideally I'm not wanting to require that knowledge.</p>
  
  <p>Is there an approach I'm overlooking?</p>