php://input 返回空

标签 php rest backbone.js kohana

我有 Backbone 应用程序。当模型更新时,PUT 请求转到我的服务器。

enter image description here

客户端看起来不错。但是在服务器端(PHP)我遇到了一些麻烦。当我第一次在 PHPStorm 中测试这个请求时:

file_get_contents('php://input')

返回我所期望的。但在其他时候,它总是返回空的。我重新启动了 Apache - 没有任何帮助。

我知道

Note: A stream opened with php://input can only be read once;

但我认为这意味着一个请求。一生不止一次 :) 我的错误在哪里?

最佳答案

这是 Kohana 问题。在 Kohana_Request 类中有一段代码,已经打开了 php://input stream

if ($method !== HTTP_Request::GET)
{
    // Ensure the raw body is saved for future use
    $body = file_get_contents('php://input');
}

关于php://input 返回空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13546660/

相关文章:

javascript - 如何让 Grunt-Contrib-Jasmine 执行规范并加载依赖项?

php - 是否可以在action.php中自动插入数据?

java - Sugarcrm - 通过 REST 的 session ID 无效 - 帖子太大?

javascript - 通过 JQuery .ajax 将数据保存到数据库

java - Jersey 服务器端异步 API 未按预期工作

java - 是否可以从 RestEASY MessageBodyReaderInterceptor 中的 MessageBodyReaderContext 获取 @PathParam 或 @QueryParam?

javascript - 过滤 Backbone 模型上单个属性的多个值

javascript - Backbone.js 比较器功能无法正常工作

php - 在PHP中,二维数组中的行数和列数?

php - 如何在 PHP HEREDOC 中使用 jQuery $