Edit report at http://bugs.php.net/bug.php?id=53444&edit=1

 ID:                 53444
 Updated by:         il...@php.net
 Reported by:        h...@php.net
 Summary:            get_headers and $http_response_header returns
                     unusable formatting
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Streams related
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The reason you get multiple headers is because the website you are
trying to 

access is redirecting the URL and by default the headers from all
requests are 

being returned. If you don't want redirects to be followed, set the
stream context 

parameter max_redirects to 0.


Previous Comments:
------------------------------------------------------------------------
[2010-12-01 23:38:50] h...@php.net

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 this bug report at http://bugs.php.net/bug.php?id=53444&edit=1

Reply via email to