Mombu the Php Forum

  Mombu the Php Forum > Php > #41051 : Stream Context 'header' option ignored if value not of type array


User Name
Password
REGISTER NOW! Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
1 8th October 16:32
tony2001
External User
 
Posts: 1
Default #41051 : Stream Context 'header' option ignored if value not of type array



ID: 41051
Updated by: tony2001@php.net
Reported By: chris dot vigelius at gmx dot net
-Status: Open
+Status: Feedback
Bug Type: Streams related
Operating System: Linux (Ubuntu Edgy)
PHP Version: 5.2.1
New Comment:

Please disable --curl-wrappers and try again.


Previous Comments:
------------------------------------------------------------------------

[2007-04-11 12:36:07] chris dot vigelius at gmx dot net

Note: my php was compiled with '--with-curl' '--with-curlwrappers',
if that matters.

------------------------------------------------------------------------

[2007-04-11 12:28:14] chris dot vigelius at gmx dot net

Description:
------------
the http wrapper ignores 'header' option in stream_create_context( ) if
the value is not given as a simple array; neither a string nor a map
(e.g. array('X-My-Header' => 'test')) will cause the additional headers
to be sent.

Reproduce code:
---------------
// given as string, the header will not be sent
$url = 'http://protectedstuff.com';
$auth = base64_encode('userassword');
$header = "Authorization: Basic $auth";
$opts = array( 'http' => array ('method'=>'GET',
'header'=>$header));
$ctx = stream_context_create($opts);
file_get_contents($url,false,$ctx);

// only if $header is an array, it will be sent
$url = 'http://protectedstuff.com';
$auth = base64_encode('userassword');
$header = array("Authorization: Basic $auth");
$opts = array( 'http' => array ('method'=>'GET',
'header'=>$header));
$ctx = stream_context_create($opts);
file_get_contents($url,false,$ctx);

Expected result:
----------------
// In BOTH cases, one would expect the following headers to be sent
// with the request

GET / HTTP/1.1

User-Agent: PHP/5.2.1

Host: protectedstuff.com

Pragma: no-cache

Accept: */*

Authorization: Basic dXNlcjpwYXNzd29yZA=


Actual result:
--------------
// The first request is sent with the following headers instead

GET / HTTP/1.1

User-Agent: PHP/5.2.1

Host: protectedstuff.com

Pragma: no-cache

Accept: */*

(note that there is no 'Authorization:' header)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=41051&edit=1
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes







Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
Also visit Ogoun the Usenet Archive
666