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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chopins dot xiao at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC