|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-11 16:16 UTC] iliaa@php.net
-Status: Open
+Status: Bogus
[2010-12-11 16:16 UTC] iliaa@php.net
[2010-12-11 19:40 UTC] hm2k@php.net
-Status: Bogus
+Status: Open
[2010-12-11 19:40 UTC] hm2k@php.net
[2010-12-12 19:40 UTC] iliaa@php.net
-Status: Open
+Status: Bogus
[2010-12-12 19:40 UTC] iliaa@php.net
[2010-12-13 12:17 UTC] hm2k@php.net
-Status: Bogus
+Status: Feedback
[2010-12-13 12:17 UTC] hm2k@php.net
[2010-12-13 12:43 UTC] aharvey@php.net
-Status: Feedback
+Status: Bogus
[2010-12-13 12:43 UTC] aharvey@php.net
[2010-12-13 15:03 UTC] hm2k@php.net
-Status: Bogus
+Status: Re-Opened
[2010-12-13 15:03 UTC] hm2k@php.net
[2010-12-13 15:35 UTC] iliaa@php.net
-Status: Re-Opened
+Status: Bogus
[2010-12-13 15:35 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 08:00:02 2025 UTC |
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 )