Req #60584 [Com]: headers_list() should return in a `$key => $value` fashion

2011-12-22 Thread toms at mindboiler dot lv
Edit report at https://bugs.php.net/bug.php?id=60584&edit=1

 ID: 60584
 Comment by: toms at mindboiler dot lv
 Reported by:toms at mindboiler dot lv
 Summary:headers_list() should return in a `$key => $value`
 fashion
 Status: Wont fix
 Type:   Feature/Change Request
 Package:Network related
 Operating System:   CentOS 2.6.18-274.12.1.el5xen
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

For repeated headers you can always use multidimensional array. It wouldn't be 
deeper than two levels anyways.

Like:
array(5) {
  ["X-Powered-By"]=>
  string(23) "PHP/5.3.3"
  ["Expires"]=>
  string(38) "Thu, 19 Nov 1981 08:52:00 GMT"
  ["Cache-Control"]=>
  string(77) "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
  ["Pragma"]=>
  string(16) "no-cache"
  ["Test-Header"]=>
  string(28) "A random result"
  ["Set-Cookie"]=>
  array(2) {
[0]=>
string(7) "foo=bar"
[1]=>
string(7) "abc=123"
  }
}

Or, since Cookies are pretty predictable, associate them to keys too, or 
headers_list($flags) and add specific headers flags.

But, yes... The evilness of backwards compatibility, that ruins future 
functionality.


Previous Comments:

[2011-12-22 02:27:03] anon at anon dot anon

This could not work. Each sent cookie in an HTTP response has its own 
Set-Cookie header, and there is no syntax accepted by browsers for combining 
them into one (separators like commas or semi-colons already have other 
meanings in the Set-Cookie syntax). Blame Netscape for coming up with that, but 
17 years later there's nothing that can be done about it.

Example:

setcookie('foo', 'bar');
setcookie('abc', '123');

var_dump(headers_list());

Output:

array(2) {
  [0]=>
  string(19) "Set-Cookie: foo=bar"
  [1]=>
  string(19) "Set-Cookie: abc=123"
}

See also: http://curl.haxx.se/rfc/cookie_spec.html


[2011-12-21 15:56:36] cataphr...@php.net

While I don't think HTTP allows repeated headers, they're common in the wild, 
so key => value is not an option (maybe if the value was an array, but in any 
case both options break backwards compatibility).

Thank you for the suggestion, anyway.

----------------
[2011-12-21 12:37:53] toms at mindboiler dot lv

Changed the summary a little, OS version.


[2011-12-21 12:34:34] toms at mindboiler dot lv

Description:

The function headers_list() returns the headers in a numeric array fashion, 
although, headers are, AFAIK, always in a `Key: Value` fashion, therefore, 
associative array would be a better choice.

More on this, header_remove() works by simply passing the key, therefore, in 
background, headers have their key representation, I suppose.

I've made an example function that uses this function, for a header lookup, but 
ends up in "lots of lines" compared to what could be replaced with one: 
https://gist.github.com/1505803

P.S. This is my first file in PHP Bugs section, please guide me if I have given 
not enough information.

Test script:
---
header('Test-Header: A random result');
var_dump(headers_list());

Expected result:

array(5) {
  ["X-Powered-By"]=>
  string(23) "PHP/5.3.3"
  ["Expires"]=>
  string(38) "Thu, 19 Nov 1981 08:52:00 GMT"
  ["Cache-Control"]=>
  string(77) "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
  ["Pragma"]=>
  string(16) "no-cache"
  ["Test-Header"]=>
  string(28) "A random result"
}

Actual result:
--
array(5) {
  [0]=>
  string(23) "X-Powered-By: PHP/5.3.3"
  [1]=>
  string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
  [2]=>
  string(77) "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0"
  [3]=>
  string(16) "Pragma: no-cache"
  [4]=>
  string(28) "Test-Header: A random result"
}






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60584&edit=1


Req #60584 [Opn]: headers_list() should return in a `$key => $value` fashion

2011-12-21 Thread toms at mindboiler dot lv
Edit report at https://bugs.php.net/bug.php?id=60584&edit=1

 ID: 60584
 User updated by:toms at mindboiler dot lv
 Reported by:toms at mindboiler dot lv
-Summary:headers_list should return in a key => value fashion
+Summary:headers_list() should return in a `$key => $value`
 fashion
 Status: Open
 Type:   Feature/Change Request
 Package:Network related
-Operating System:   CentOS 2.6.18
+Operating System:   CentOS 2.6.18-274.12.1.el5xen
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

Changed the summary a little, OS version.


Previous Comments:

[2011-12-21 12:34:34] toms at mindboiler dot lv

Description:

The function headers_list() returns the headers in a numeric array fashion, 
although, headers are, AFAIK, always in a `Key: Value` fashion, therefore, 
associative array would be a better choice.

More on this, header_remove() works by simply passing the key, therefore, in 
background, headers have their key representation, I suppose.

I've made an example function that uses this function, for a header lookup, but 
ends up in "lots of lines" compared to what could be replaced with one: 
https://gist.github.com/1505803

P.S. This is my first file in PHP Bugs section, please guide me if I have given 
not enough information.

Test script:
---
header('Test-Header: A random result');
var_dump(headers_list());

Expected result:

array(5) {
  ["X-Powered-By"]=>
  string(23) "PHP/5.3.3"
  ["Expires"]=>
  string(38) "Thu, 19 Nov 1981 08:52:00 GMT"
  ["Cache-Control"]=>
  string(77) "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
  ["Pragma"]=>
  string(16) "no-cache"
  ["Test-Header"]=>
  string(28) "A random result"
}

Actual result:
--
array(5) {
  [0]=>
  string(23) "X-Powered-By: PHP/5.3.3"
  [1]=>
  string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
  [2]=>
  string(77) "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0"
  [3]=>
  string(16) "Pragma: no-cache"
  [4]=>
  string(28) "Test-Header: A random result"
}






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60584&edit=1


[PHP-BUG] Req #60584 [NEW]: headers_list should return in a key => value fashion

2011-12-21 Thread toms at mindboiler dot lv
From: 
Operating system: CentOS 2.6.18
PHP version:  Irrelevant
Package:  Network related
Bug Type: Feature/Change Request
Bug description:headers_list should return in a key => value fashion

Description:

The function headers_list() returns the headers in a numeric array fashion,

although, headers are, AFAIK, always in a `Key: Value` fashion, therefore,

associative array would be a better choice.

More on this, header_remove() works by simply passing the key, therefore,
in 
background, headers have their key representation, I suppose.

I've made an example function that uses this function, for a header lookup,
but 
ends up in "lots of lines" compared to what could be replaced with one: 
https://gist.github.com/1505803

P.S. This is my first file in PHP Bugs section, please guide me if I have
given 
not enough information.

Test script:
---
header('Test-Header: A random result');
var_dump(headers_list());

Expected result:

array(5) {
  ["X-Powered-By"]=>
  string(23) "PHP/5.3.3"
  ["Expires"]=>
  string(38) "Thu, 19 Nov 1981 08:52:00 GMT"
  ["Cache-Control"]=>
  string(77) "no-store, no-cache, must-revalidate, post-check=0,
pre-check=0"
  ["Pragma"]=>
  string(16) "no-cache"
  ["Test-Header"]=>
  string(28) "A random result"
}

Actual result:
--
array(5) {
  [0]=>
  string(23) "X-Powered-By: PHP/5.3.3"
  [1]=>
  string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
  [2]=>
  string(77) "Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, 
pre-check=0"
  [3]=>
  string(16) "Pragma: no-cache"
  [4]=>
  string(28) "Test-Header: A random result"
}

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