有关HTTP标头中的大小限制的奇怪问题

时间:2019-01-16 16:09:48

标签: http curl header

上下文:我维护一种Web服务服务器,但是有一个特定的实现:Web服务发送的所有数据都位于http标头中。这意味着响应中只有http标头(没有正文部分)。该Web服务作为Windows服务运行。消费者是我的PHP代码,它通过CURL库调用Web服务。所有这些都已投入生产3年,并且运行良好。我最近不得不建立一个开发环境。

1-我将Windows 7专业版的Web服务作为Windows服务。

2-我在另一个Windows 7 Pro(WAMP + CURL)中安装了我的PHP使用者。

3-我的PHP代码调用Web服务并显示原始响应。

4-在这种情况下,会出现问题:如果响应包含的字符超过1215个,则我有一个空响应(但没有错误消息)。


5-我在一个新的Linux ubuntu上安装了我的PHP代码(完全相同):我有同样的问题。


6-我在一个新的Linux centos上安装了我的PHP代码(完全相同):我没有这个问题。


7-我在互联网上读到很多有关http标头大小限制的信息,我认为今天这不是问题的原因。

8-我检查了Apache,PHP,Curl上的所有大小限制参数,但没有找到相关的东西。

如果某人有一些信息。欢迎所有曲目。谢谢

2 个答案:

答案 0 :(得分:0)

不是一个答案,但是想说在Apache 2.4.33的mod_php下使用PHP 7.2.5,我无法重现您的问题,因为在从1字节到10,000甚至100,000字节的范围内发送任何内容我都没有问题标头:

enter image description here

这是我的producer.php:

<?php
$size=((int)($_GET['s'] ?? 1));
header("X-size: {$size}");
$data=str_repeat("a",$size);
header("X-data: {$data}");
http_response_code(204); // 204 NO CONTENT

,无论我点击了http://127.0.0.1/producer.php?s=1还是http://127.0.0.1/producer.php?s=10000甚至是http://127.0.0.1/producer.php?s=100000,返回的数据都没有问题,如上面的屏幕快照所示。您可以使用我的producer.php代码重现该问题吗?

顺便说一句,有趣的是,当我尝试1百万个字节时,我从curl中得到了这个错误:

$ curl -I http://127.0.0.1/producer.php?s=1000000
HTTP/1.1 204 No Content
Date: Wed, 16 Jan 2019 20:11:25 GMT
Server: Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.5
X-Powered-By: PHP/7.2.5
X-size: 1000000
curl: (27) Rejected 104960 bytes header (max is 102400)!

答案 1 :(得分:0)

Hanshenrik,
如您所说,我还使用了CURLOPT_VERBOSE。这是2个卷曲日志。 唯一的区别是线 <*停止了暂停流!>在Ubuntu curl日志中。


Ubuntu女巫的CURL日志有问题:

*   Trying 192.168.1.205...
* TCP_NODELAY set
* Connected to 192.168.1.205 (192.168.1.205) port 8084 (#0)
> POST /datasnap/rest/TServerMethods/%22W_GetDashboard%22/ HTTP/1.1
Host: 192.168.1.205:8084
Accept-Encoding: gzip,deflate
Accept: application/json
Content-Type: text/xml; charset=utf-8
Pragma: dssession=146326.909376.656191
Content-Length: 15
* upload completely sent off: 15 out of 15 bytes

< HTTP/1.1 200 OK
< Connection: close
< Content-Encoding: deflate
< Content-Type: application/json
< Content-Length: 348
< Date: Thu, 17 Jan 2019 15:27:03 GMT
< Pragma: dssession=146326.909376.656191,dssessionexpires=3600000
< 
* stopped the pause stream!
* Closing connection 0

Centos女巫的CURL日志没有问题:

* About to connect() to 192.168.1.205 port 8084 (#1)
*   Trying 192.168.1.205...
* Connected to 192.168.1.205 (192.168.1.205) port 8084 (#1)
> POST /datasnap/rest/TServerMethods/%22W_GetDashboard%22/ HTTP/1.1
Host: 192.168.1.205:8084
Accept-Encoding: gzip,deflate
Accept: application/json
Content-Type: text/xml; charset=utf-8
Pragma: dssession=3812.553164.889594
Content-Length: 15

* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 200 OK
< Connection: close
< Content-Encoding: deflate
< Content-Type: application/json
< Content-Length: 348
< Date: Thu, 17 Jan 2019 15:43:39 GMT
< Pragma: dssession=3812.553164.889594,dssessionexpires=3600000
< 
* Closing connection 1