首页 > 解决方案 > HTTP Response 是否有可能添加内容?

问题描述

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

我在 PHP 中发送的只是<?php die('END'); ?>

这个“3”从何而来?在响应中,这个零是从哪里来的?

要求:

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

标签: phphttppostnetworkingresponse

解决方案


这些数字表示分块 HTTP 输出的块的长度。

请参阅https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example

如果您想将其关闭,请参阅此 SO 帖子


推荐阅读