|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesmatrix75 (last revision 2016-07-27 20:27 UTC by ilyeshaji at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-04-11 12:36 UTC] chris dot vigelius at gmx dot net
[2007-04-11 14:11 UTC] tony2001@php.net
[2007-04-19 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 20:00:02 2025 UTC |
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('user:password'); $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('user:password'); $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)