From:             
Operating system: Windows 7 Pro x64
PHP version:      5.2.13
Package:          cURL related
Bug Type:         Bug
Bug description:file_get_contents('php://input') - empty string if called more 
than once

Description:
------------
Second and consecutive calls of file_get_contents('php://input') return
empty string if client issued an HTTP command other than 'GET' or 'POST'
(see example code). If 'GET' or 'POST' HTTP command was issued
file_get_contents('php://input') works correctly.



Not sure if this is cURL related bug, maybe some other PHP package is
responsible.



I am using Apache 2.2 and IE8.

Test script:
---------------
#bug_curl.php

$hcurl = curl_init();

curl_setopt($hcurl, CURLOPT_URL, 'http://test/bug.php');

curl_setopt($hcurl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($hcurl, CURLOPT_HTTPHEADER, array('Content-Type:
text/plain'));

curl_setopt($hcurl, CURLOPT_POSTFIELDS, 'some request text');

curl_setopt($hcurl, CURLOPT_CUSTOMREQUEST, 'DELETE');

//curl_setopt($hcurl, CURLOPT_HTTPGET, true); - this works ok

//curl_setopt($hcurl, CURLOPT_POST, true); - this works ok

$out = curl_exec($hcurl);

curl_close($hcurl);

echo '<pre>'.htmlspecialchars($out).'</pre>';



# bug.php

var_dump(file_get_contents('php://input'));

var_dump(file_get_contents('php://input')); // returns empty string if HTTP
command is not 'GET' or POST'

var_dump(apache_request_headers());



Expected result:
----------------
string(17) "some request text"

string(17) "some request text"

array(4) {

  ["Host"]=>

  string(4) "test"

  ["Accept"]=>

  string(3) "*/*"

  ["Content-Type"]=>

  string(10) "text/plain"

  ["Content-Length"]=>

  string(2) "17"

}





Actual result:
--------------
string(17) "some request text"

string(0) ""

array(4) {

  ["Host"]=>

  string(4) "test"

  ["Accept"]=>

  string(3) "*/*"

  ["Content-Type"]=>

  string(10) "text/plain"

  ["Content-Length"]=>

  string(2) "17"

}





-- 
Edit bug report at http://bugs.php.net/bug.php?id=51592&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51592&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51592&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51592&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51592&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51592&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51592&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51592&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51592&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51592&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51592&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51592&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51592&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51592&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51592&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51592&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51592&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51592&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51592&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51592&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51592&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51592&r=mysqlcfg

Reply via email to