使用x-www-form-urlencoded content-type返回错误的int

时间:2013-09-25 07:58:32

标签: php

我有这样的问题:

这是一个文件:

test_info.php

<?php

var_dump(strlen(file_get_contents('php://input')),
  $_SERVER['CONTENT_LENGTH']);

?>

这是POST'ing文件:

<?php

echo file_get_contents('http://localhost/test_info.php', false, stream_context_create(array('http' => array('method' => 'POST', 'content' => str_repeat('a', 1024*1024*2), 'header' => 'Content-type: application/x-www-form-urlencoded'))));

?>

当我使用内容类型x-www-form-urlencoded时,我从var_dump得到了这样的结果:

INT(1044736) string(7)“2097152”

如果我将\ n字符放在'Content-type:\ n'中,那么它会返回正确的结果:

INT(2097152) string(7)“2097152”

如果我将content-type更改为multipart / form-data,它也会返回正确的结果。 INT(2097152)

P.S。在其他服务器上我也正确地得到它,而不修改内容类型。

也许有人知道为什么它回来了错呢? (切割内容)

感谢

0 个答案:

没有答案