From:             hm2k
Operating system: 
PHP version:      5.3.3
Package:          Streams related
Bug Type:         Bug
Bug description:get_headers and $http_response_header returns unusable 
formatting

Description:
------------
The get_headers() function and the $http_response_header variable often
returns multiple headers combined into a completely unusable format.

Test script:
---------------
<pre>

<?php

/*



The get_headers() function and the $http_response_header variable often
returns

  multiple headers combined into a completely unusable format.



*/



echo "Testing the \$http_response_header format\n";

file_get_contents('http://google.com/');

print_r($http_response_header);



echo "Testing the normal get_headers format\n";

$headers=get_headers('http://google.com/');

print_r($headers);



echo "Testing the get_headers format with keys\n";

$headers=get_headers('http://google.com/',1);

print_r($headers);



?>

Expected result:
----------------
Each set of headers from each request should be separated into another
array, rather than simply appended to the existing ones.



There is currently no safe way to separate the returned values into a
usable format. The get_headers format with keys is the worst offender of
this.

Actual result:
--------------
Testing the $http_response_header format

Array

(

    [0] => HTTP/1.0 301 Moved Permanently

    [1] => Location: http://www.google.com/

    [2] => Content-Type: text/html; charset=UTF-8

    [3] => Date: Wed, 01 Dec 2010 22:36:17 GMT

    [4] => Expires: Fri, 31 Dec 2010 22:36:17 GMT

    [5] => Cache-Control: public, max-age=2592000

    [6] => Server: gws

    [7] => Content-Length: 219

    [8] => X-XSS-Protection: 1; mode=block

    [9] => HTTP/1.0 302 Found

    [10] => Location: http://www.google.co.uk/

    [11] => Cache-Control: private

    [12] => Content-Type: text/html; charset=UTF-8

    [13] => Set-Cookie:
PREF=ID=4a205a8a49c12cc1:FF=0:TM=1291242977:LM=1291242977:S=nhA-vebjo6ayX0bQ;
expires=Fri, 30-Nov-2012 22:36:17 GMT; path=/; domain=.google.com

    [14] => Set-Cookie:
NID=41=LcFt9zVP6L3dEVMKDUeNblPFQVRlOJaak9BjEUnZErgDkDh9yjljWhydKUteQdcqGh4PM0gaVJlyLT6CEu6K_LpFYJhRJRMkgy7-u45iMOa4xvItP26T_03rqUm-Lrrv;
expires=Thu, 02-Jun-2011 22:36:17 GMT; path=/; domain=.google.com;
HttpOnly

    [15] => Date: Wed, 01 Dec 2010 22:36:17 GMT

    [16] => Server: gws

    [17] => Content-Length: 221

    [18] => X-XSS-Protection: 1; mode=block

    [19] => HTTP/1.0 200 OK

    [20] => Date: Wed, 01 Dec 2010 22:36:17 GMT

    [21] => Expires: -1

    [22] => Cache-Control: private, max-age=0

    [23] => Content-Type: text/html; charset=ISO-8859-1

    [24] => Set-Cookie:
PREF=ID=16ffcfbf48f03139:FF=0:TM=1291242977:LM=1291242977:S=Niy-I-NoOBYJK2Tl;
expires=Fri, 30-Nov-2012 22:36:17 GMT; path=/; domain=.google.co.uk

    [25] => Set-Cookie:
NID=41=eXX6NtkDo7xtT_Y7l3MVRtVznVjPE0fUUwfcmcSTXOX_80oJhSDTi_NJvidjgq_fwl3xOTvMTXatxlUqJPZsSPk2b8jIZ-oG4_tO9Eyf_beK0jqoJ20u72Ukhsydzxih;
expires=Thu, 02-Jun-2011 22:36:17 GMT; path=/; domain=.google.co.uk;
HttpOnly

    [26] => Server: gws

    [27] => X-XSS-Protection: 1; mode=block

)

Testing the normal get_headers format

Array

(

    [0] => HTTP/1.0 301 Moved Permanently

    [1] => Location: http://www.google.com/

    [2] => Content-Type: text/html; charset=UTF-8

    [3] => Date: Wed, 01 Dec 2010 22:36:17 GMT

    [4] => Expires: Fri, 31 Dec 2010 22:36:17 GMT

    [5] => Cache-Control: public, max-age=2592000

    [6] => Server: gws

    [7] => Content-Length: 219

    [8] => X-XSS-Protection: 1; mode=block

    [9] => HTTP/1.0 302 Found

    [10] => Location: http://www.google.co.uk/

    [11] => Cache-Control: private

    [12] => Content-Type: text/html; charset=UTF-8

    [13] => Set-Cookie:
PREF=ID=1c5409426fc05ac7:FF=0:TM=1291242978:LM=1291242978:S=Gq5q1jDdprguyJVX;
expires=Fri, 30-Nov-2012 22:36:18 GMT; path=/; domain=.google.com

    [14] => Set-Cookie:
NID=41=YVFzP9yX2jgAGZzNfMYIIjZ2BE3FBZGe35hvkcZnv_vXG_Y6-3WWfeY3X5_B7ggaA7-bLOR2WihGFyFTo_9etxMb-o5KbD6wxs3chDweWERpzOaRzSwRdKZZ0r469lOq;
expires=Thu, 02-Jun-2011 22:36:18 GMT; path=/; domain=.google.com;
HttpOnly

    [15] => Date: Wed, 01 Dec 2010 22:36:18 GMT

    [16] => Server: gws

    [17] => Content-Length: 221

    [18] => X-XSS-Protection: 1; mode=block

    [19] => HTTP/1.0 200 OK

    [20] => Date: Wed, 01 Dec 2010 22:36:18 GMT

    [21] => Expires: -1

    [22] => Cache-Control: private, max-age=0

    [23] => Content-Type: text/html; charset=ISO-8859-1

    [24] => Set-Cookie:
PREF=ID=72fb7f7330dc6dda:FF=0:TM=1291242978:LM=1291242978:S=8hdaRNIKWI_17QQW;
expires=Fri, 30-Nov-2012 22:36:18 GMT; path=/; domain=.google.co.uk

    [25] => Set-Cookie:
NID=41=emzDdkZVlIzPUExRMV6yXykCd0Jqrc665mzd5smnyV-MCBqEeC7wEndKmpsRqgb5M3_2dfdEK1Fbjwq0OPd87oz9UFjVYXqPqKABcPHtp_FWZw4rUluDtHeBI04rCyHH;
expires=Thu, 02-Jun-2011 22:36:18 GMT; path=/; domain=.google.co.uk;
HttpOnly

    [26] => Server: gws

    [27] => X-XSS-Protection: 1; mode=block

)

Testing the get_headers format with keys

Array

(

    [0] => HTTP/1.0 301 Moved Permanently

    [Location] => Array

        (

            [0] => http://www.google.com/

            [1] => http://www.google.co.uk/

        )



    [Content-Type] => Array

        (

            [0] => text/html; charset=UTF-8

            [1] => text/html; charset=UTF-8

            [2] => text/html; charset=ISO-8859-1

        )



    [Date] => Array

        (

            [0] => Wed, 01 Dec 2010 22:36:18 GMT

            [1] => Wed, 01 Dec 2010 22:36:18 GMT

            [2] => Wed, 01 Dec 2010 22:36:18 GMT

        )



    [Expires] => Array

        (

            [0] => Fri, 31 Dec 2010 22:36:18 GMT

            [1] => -1

        )



    [Cache-Control] => Array

        (

            [0] => public, max-age=2592000

            [1] => private

            [2] => private, max-age=0

        )



    [Server] => Array

        (

            [0] => gws

            [1] => gws

            [2] => gws

        )



    [Content-Length] => Array

        (

            [0] => 219

            [1] => 221

        )



    [X-XSS-Protection] => Array

        (

            [0] => 1; mode=block

            [1] => 1; mode=block

            [2] => 1; mode=block

        )



    [1] => HTTP/1.0 302 Found

    [Set-Cookie] => Array

        (

            [0] =>
PREF=ID=2325ca533177d4ef:FF=0:TM=1291242978:LM=1291242978:S=nOg-8n0YOwaShUAK;
expires=Fri, 30-Nov-2012 22:36:18 GMT; path=/; domain=.google.com

            [1] =>
NID=41=R4dJOFuh4Jh_rqx2gNOgUJAjgn9ooyONvaut5VUv18l7G58_9NIMP4WWLWdY4_8hgsVQPdpzljkjZHwxmvKjROrM1-52DndexrKzVs52oyysf93A_HlBpc2B8sRb5s1-;
expires=Thu, 02-Jun-2011 22:36:18 GMT; path=/; domain=.google.com;
HttpOnly

            [2] =>
PREF=ID=5375620b1f946c18:FF=0:TM=1291242978:LM=1291242978:S=HpY6OMdBxJ5saTyh;
expires=Fri, 30-Nov-2012 22:36:18 GMT; path=/; domain=.google.co.uk

            [3] =>
NID=41=Hif27kRrMTf26VBtWJg8uOojHHEUZGp1w-a-IJVRQIGZJb3RwR9qPSK8hPtPni9pTcljP9WuLfFUgkReiTQJLpJTLuzG4Ymlo_dinxubk2XHC9sXFzvkIxWtZ0lEnLAZ;
expires=Thu, 02-Jun-2011 22:36:18 GMT; path=/; domain=.google.co.uk;
HttpOnly

        )



    [2] => HTTP/1.0 200 OK

)



-- 
Edit bug report at http://bugs.php.net/bug.php?id=53444&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53444&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53444&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53444&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53444&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53444&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53444&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53444&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53444&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53444&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53444&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53444&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53444&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53444&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53444&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53444&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53444&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53444&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53444&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53444&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53444&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53444&r=mysqlcfg

Reply via email to