php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67932 php://input always empty when do not use http request
Submitted: 2014-08-29 12:53 UTC Modified: 2015-04-19 19:48 UTC
From: geloen dot eric at gmail dot com Assigned: mike (profile)
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.5.16 OS: Ubuntu 14.04 (64 bits)
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: geloen dot eric at gmail dot com
New email:
PHP Version: OS:

 

 [2014-08-29 12:53 UTC] geloen dot eric at gmail dot com
Description:
------------
Hey!

I'm not able to access php://input stream when I don't use the pecl_http extension at all in my script (the extension is only loaded in PHP). I have spotted https://bugs.php.net/bug.php?id=59239 but it is not similar as the library internally uses the php://input stream, so it is normal it becomes empty but here, I don't read it at all somewhere and don't use any class which comes from the library.

Test script:
---------------
Send a request where the body is not automatically decoded by PHP such as PATCH, PUT, OPTIONS, etc... Something like:

PUT http://example.com/requestbodytest.php HTTP/1.1
Host: example.com
Connection: close
Content-Type: text/xml
Content-Length: 58

<?xml version="1.0" encoding="utf-8" ?>
<body>test</body>

Then, just try to access the php://input stream:

readfile('php://input');

Expected result:
----------------
<?xml version="1.0" encoding="utf-8" ?>
<body>test</body>

Actual result:
--------------
Empty string

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-10 16:38 UTC] mike@php.net
-Assigned To: +Assigned To: mike
 [2014-09-15 12:10 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-09-15 12:10 UTC] mike@php.net
Which version of pecl_http are you using?
 [2014-09-19 18:29 UTC] geloen dot eric at gmail dot com
-Status: Feedback +Status: Closed
 [2014-09-19 18:29 UTC] geloen dot eric at gmail dot com
The bug seems fixed with the latest release (2.1.1).
 [2014-09-19 19:58 UTC] geloen dot eric at gmail dot com
-Status: Closed +Status: Assigned
 [2014-09-19 19:58 UTC] geloen dot eric at gmail dot com
Sorry but in fact, it is still relevant with the latest release (2.1.1)
 [2014-09-25 13:36 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-09-25 13:36 UTC] mike@php.net
I cannot replicate this behavior on 5.5 and 5.6
See https://github.com/php/pecl-http-pecl_http/blob/master/tests/bug67932.phpt
 [2014-10-06 14:41 UTC] geloen dot eric at gmail dot com
-Status: Feedback +Status: Assigned
 [2014-10-06 14:41 UTC] geloen dot eric at gmail dot com
I confirm I still dig into the issue with the 2.1.2 version of the library. I just executed the testsuite on my laptop and I got multiple failures:

TOTAL TIME: 00:21
129 PASSED TESTS
0 SKIPPED TESTS
15 FAILED TESTS:
pecl-http/tests/bug67932.phpt
pecl-http/tests/client016.phpt
pecl-http/tests/envrequestbody001.phpt
pecl-http/tests/envrequestbody002.phpt
pecl-http/tests/envrequestbody003.phpt
pecl-http/tests/envrequestjson002.phpt
pecl-http/tests/envresponse007.phpt
pecl-http/tests/envresponse009.phpt
pecl-http/tests/envresponse010.phpt
pecl-http/tests/envresponseranges001.phpt
pelc-http/tests/info.phpt
pecl-http/tests/info_001.phpt
pecl-http/tests/message002.phpt
pecl-http/tests/message006.phpt
pecl-http/tests/messageparser001.phpt

I see the test you added for my issue failing. if it is working on your computer, I don't really know what is wrong on my side. I use the latest version of raphf and propro and I load them as following in my conf (very last extensions loaded):

extension=raphf.so
extension=propro.so
extension=http.so
 [2014-10-06 19:39 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-10-06 19:39 UTC] mike@php.net
Could you please mail me the test logs to mike@php.net?

Thank you!
 [2014-10-07 18:39 UTC] geloen dot eric at gmail dot com
-Status: Feedback +Status: Assigned
 [2014-10-07 18:39 UTC] geloen dot eric at gmail dot com
What did you mean by the log? I run the tests with pear (pear run-tests) and the output copy/pasted is the one coming from the log.
 [2014-10-08 09:33 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-10-08 09:33 UTC] mike@php.net
Duh, well, so run-tests from PEAR?

I doubt that is in sync with the official run-tests.php...

Did it leave *.log files in the tests directory?
 [2014-10-08 18:59 UTC] geloen dot eric at gmail dot com
-Status: Feedback +Status: Assigned
 [2014-10-08 18:59 UTC] geloen dot eric at gmail dot com
I just sent you the logs.
 [2014-10-15 16:18 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-10-15 16:18 UTC] mike@php.net
Ok, so, obviously `pear run-tests` is old and shouldn't be used. The test suite depends on various features apparently not available in PEAR's run-tests.

Anyway, that doesn't bring us closer to your problem's solution.
 [2014-10-29 20:17 UTC] geloen dot eric at gmail dot com
-Status: Feedback +Status: Assigned
 [2014-10-29 20:17 UTC] geloen dot eric at gmail dot com
I have tested a PHPUnit testsuite which fails on my laptop with travis-ci (https://travis-ci.org/egeloen/ivory-http-adapter/builds/39419797) and it works, so it can only be related to my PHP configuration. Futhermore, I have noticed this only happens when there are files sent in the request... I don't understand what can be the cause.
 [2014-11-06 14:42 UTC] mike@php.net
-Status: Assigned +Status: Feedback
 [2014-11-06 14:42 UTC] mike@php.net
Sorry, I can not follow. Should I see any pecl_http relevant info there?
 [2014-12-30 10:42 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2014-12-30 19:32 UTC] geloen dot eric at gmail dot com
I will try to provide a more simple script to reproduce the bug but basically, I have discovered it with a specific PHPUnit test suite which is broken on travis-ci.org when I just install and enable the pecl_http extension.

See https://travis-ci.org/egeloen/ivory-http-adapter/jobs/45464408 for the failling build.

Btw,
 [2015-04-19 14:06 UTC] geloen dot eric at gmail dot com
-Status: No Feedback +Status: Closed
 [2015-04-19 14:06 UTC] geloen dot eric at gmail dot com
I just updated the package and the bug is gone. So, closing :)
 [2015-04-19 19:48 UTC] mike@php.net
Thanks for the feedback!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC