1
HTTP/1.1 200 OK\r\n
Date: Tue, 29 Jun 2021 10:48:59 GMT\r\n
Server: Apache\r\n
Upgrade: h2\r\n
Connection: Upgrade, close\r\n
Vary: Accept-Encoding\r\n
Transfer-Encoding: chunked\r\n
Content-Type: text/html; charset=UTF-8\r\n
\r\n
3\r\nEND\r\n0\r\n\r\n

What I am sending in PHP is only <?php die('END'); ?>

Where does this '3' come from? And where does this zero come from, in the response?

Request:

POST / HTTP/1.1\r\n
Host: " . $host . "\r\n
Content-type: application/x-www-form-urlencoded\r\n
Content-length: ".strlen($str)."\r\n
Connection: Close\r\n\r\n
str=string
Z0q
  • 1,689
  • 3
  • 28
  • 57

1 Answers1

1

The numbers represent the length of the chunks of the chunked HTTP output.

See https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example

If you'd like to turn it off, see this SO post.

Code4R7
  • 2,600
  • 1
  • 19
  • 42
  • Thanks! Very helpful. I decided to add a Content-Length header to the response, which prevents it from making chunks – Z0q Jun 29 '21 at 12:18