REST request data can't be read in 'put' method

前端 未结 2 1330
北荒
北荒 2020-12-18 00:11

I\'m trying to develop a RESTful API with PHP without using frameworks. While processing the request, the client data cannot be read using this: parse_str(file_get_con

2条回答
  •  清酒与你
    2020-12-18 00:25

    Could it be that there's something wrong with the web server?

    Actually yes. After banging my head on this for a few hours, I found that the culprit for the missing data was this:

    Note: Prior to PHP 5.6, a stream opened with php://input could only be read once
    

    Another piece of code was accessing the php://input before my code, and on servers with php < 5.6, this caused the input to be lost.

    Only on PUT requests that is.

提交回复
热议问题