file_get_contents('php:// input')返回带有PUT请求的空字符串

sro*_*oes 10 php fastcgi iis-8.5

在将我们的一个网站从带有Apache的Linux移动到带有通过FastCGI运行PHP 5.6的IIS(8.5)的Windows之后,我们遇到了file_get_contents('php://input')为PUT请求返回空字符串的问题.

我创建了以下测试:

<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
    strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    die(file_get_contents('php://input'));
}
?>
<!DOCTYPE html>
<html>
<head>
    <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
    <h2>POST:</h2>
    <div id="post"></div>

    <h2>PUT:</h2>
    <div id="put"></div>
    <script>
        $.ajax({
            url: '?',
            data: 'Working',
            type: 'POST'
        }).then(function(response) {
            $('#post').html(response || 'Not working');
        });

        $.ajax({
            url: '?',
            data: 'Working',
            type: 'PUT'
        }).then(function(response) {
            $('#put').html(response || 'Not working');
        });
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

结果如下:

POST:

工作

放:

不工作

可能是什么导致了这个?

sro*_*oes 1

事实证明,该问题是由 Helicon Ape 模块(支持 Apache .htaccess 和 .htpasswd 配置文件的模块)引起的。删除这个模块可以解决问题,但我仍然不知道为什么它会干扰 PUT 请求。我想我必须在他们的论坛上发布一个有关此问题的主题。