php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70576 On PUT/PATCH Methods all PHP file methods can read php://input just one time
Submitted: 2015-09-24 20:50 UTC Modified: 2015-09-25 07:28 UTC
From: chameleonbr at gmail dot com Assigned: mike (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.5.29 OS: OpenSUSE 13.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chameleonbr at gmail dot com
New email:
PHP Version: OS:

 

 [2015-09-24 20:50 UTC] chameleonbr at gmail dot com
Description:
------------
On HTTP PUT and PATCH Methods all PHP file methods can read php://input just one time.
In the method post 2 times the value appears as expected, but the put and patch methods returns only one time.

Test script:
---------------
<?php 
var_dump(file_get_contents('php://input'));
var_dump(file_get_contents('php://input'));
?>

Send DATA using HTTP POST and after HTTP PUT or PATCH.




Actual result:
--------------
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'var1=val2&var2=val2' 'http://localhost/testmethod.php'
result:
string(19) "var1=val2&var2=val2"
string(19) "var1=val2&var2=val2"

curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'var1=val2&var2=val2' 'http://localhost/testmethod.php'

result:
string(19) "var1=val2&var2=val2"
string(0) ""

curl -X PATCH -H "Content-Type: application/x-www-form-urlencoded" -d 'var1=val2&var2=val2' 'http://localhost/testmethod.php'

result:
string(19) "var1=val2&var2=val2"
string(0) ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-24 23:51 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 [2015-09-24 23:51 UTC] requinix@php.net
This was fixed in PHP 5.6.
5.5 is now only receiving security fixes so please consider upgrading.
 [2015-09-25 07:28 UTC] mike@php.net
Also, if you'd like 'application/x-www-form-urlencoded' data to end up in $_POST/$_REQUEST for request methods other than 'POST', have a look at ext-apfd: https://pecl.php.net/package/apfd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 17:01:31 2024 UTC