Edit report at http://bugs.php.net/bug.php?id=52666&edit=1
ID: 52666 Updated by: ahar...@php.net Reported by: chopins dot xiao at gmail dot com Summary: file_get_contents function can not set the HTTP headers -Status: Open +Status: Feedback Type: Bug Package: Filesystem function related Operating System: Fedora 13 PHP Version: 5.2.14 Block user comment: N New Comment: I can't reproduce this on 5.2.13 or the current 5.2 snapshot under any configuration I can come up with. Request headers always seem to be sent as expected. As 5.2 is closed for bug fixes, can you please see if the bug occurs with PHP 5.3.3? If it does, please also provide your configure line from phpinfo(). Previous Comments: ------------------------------------------------------------------------ [2010-08-22 13:04:59] chopins dot xiao at gmail dot com Description: ------------ My PHP is 5.2.13,if use under code <?php // Create a stream $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); $context = stream_context_create($opts); // Open the file using the HTTP headers set above $file = file_get_contents('http://www.example.com/', false, $context); ?> use Wireshark check HTTP request header is: User-Agent: PHP/5.2.13\r\n Host: en.wikipedia.org\r\n Accept: */*\r\n I set header not exists Test script: --------------- <?php // Create a stream $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); Expected result: ---------------- User-Agent: PHP/5.2.13\r\n Host: en.wikipedia.org\r\n Accept-language: en\r\n Cookie: foo=bar\r\n Actual result: -------------- User-Agent: PHP/5.2.13\r\n Host: en.wikipedia.org\r\n Accept: */*\r\n ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52666&edit=1