title: How does HTTP specify the end of a response for Transfer-encoding: chunked?
body: <p>From this <a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Server_response" rel="nofollow noreferrer">wikipedia example</a>
   a typical HTTP response may look like this </p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Mon, 23 May 2005 22:38:34 GMT
  Content-Type: text/html; charset=UTF-8
  Content-Encoding: UTF-8
  Content-Length: 138
  Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
  Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
  ETag: "3f80f-1b6-3e1cb03b"
  Accept-Ranges: bytes
  Connection: close
  
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;An Example Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    Hello World, this is a very simple HTML document.
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In this case because of this header:</p>
  
  <pre><code>Connection: close
  </code></pre>
  
  <p>the client will know that the HTTP body has finished, because the TCP connection will be closed, Say for example <code>Connection: close</code> wasn't present, the client would still know the HTTP body was finished because  this header:</p>
  
  <pre><code>Content-Length: 138
  </code></pre>
  
  <p>Is saying, once you get 138 bytes, we're done here. But in the case where neither of these headers are used and instead the server sends <code>Transfer-encoding: chunked</code> how does a browser know when a response has completed, so that it can move onto other things?</p>