php - 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
解决方案
这些数字表示分块 HTTP 输出的块的长度。
请参阅https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
如果您想将其关闭,请参阅此 SO 帖子。
推荐阅读
- python - on_epoch_end() 未在 keras fit_generator() 中调用
- python - 使用 Pyglet 可视化大量数据
- capl - 如何使用 CAPL 在 CANoe 中模拟错误帧并使错误计数器增加/减少?
- c# - FreshPageModelResolver.ResolvePageModel<>() 出错;
- excel - excel中的数据库vlookup有什么问题
- c# - 使用公式将项目添加到数组的更快方法
- php - FCM 成功但 android 设备未收到通知
- python - 使用python在csv文件中连续查找10个最大数字?
- amazon-web-services - AWS:如何使用 A 记录将非 Route53 域映射到 CloudFront
- docker - 无法将 docker.sock 绑定到 Docker 服务