dongwen7730 2012-04-10 06:57
浏览 40
已采纳

是否允许POST空数据?

For a web API I'm developing I want to do something similar to Facebook Graph API. A user can invite another user. To accept or reject the invitation, the other user needs to do an empty POST to:

/invitation/<invitationId>/accepted

or

/invitation/<invitationId>/rejected

However, this is not working for me as, when I POST empty data, PHP (or Apache?) returns the following error:

Request entity too large!

The POST method does not allow the data transmitted, or the data volume exceeds the capacity limit.

Obviously this is not true since the POST data is empty (I double-checked in Firebug). So my questions are:

  • Does the HTTP protocol allow POSTing empty data? If it doesn't I guess I'll just post some dummy data but I'd rather avoid this kind of hack.

  • If it is allowed, how can I make Apache/PHP allow the request?

  • 写回答

2条回答 默认 最新

  • duan5801 2012-04-10 08:17
    关注

    I guess that you want to do some kind of a RESTful api, and that's why you need to send post with no data.

    Apache/php should allow you to send empty post data, the restrictions must be imposed by some server configurations of the framework you are using

    you can test this with this simple file:

    <?php
    
    echo '<h2>This page was requested using ' . $_SERVER['REQUEST_METHOD'] . '</h2>';
    echo '<pre>';
    print_r($_POST);
    echo '</pre>';
    ?>
    <form action="" method="post">
        <input type="submit" value="Request this page using POST" />
    </form>
    

    You will see that the script detects the post request (using REQUEST_METHOD from the _SERVER superglobal) even if the _POST array is empy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分