php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52666 file_get_contents function can not set the HTTP headers
Submitted: 2010-08-22 13:04 UTC Modified: 2013-02-18 00:34 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: chopins dot xiao at gmail dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.14 OS: Fedora 13
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-08-22 13:04 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-23 05:42 UTC] aharvey@php.net
-Status: Open +Status: Feedback
 [2010-08-23 05:42 UTC] aharvey@php.net
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().
 [2013-02-18 00:34 UTC] php-bugs 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 "Open". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 02:01:31 2019 UTC