@@ -40,7 +40,15 @@ public static function http_parse_headers( $header )
4040 $ fields = explode ("\r\n" , preg_replace ('/\x0D\x0A[\x09\x20]+/ ' , ' ' , $ header ));
4141 foreach ( $ fields as $ field ) {
4242 if ( preg_match ('/([^:]+): (.+)/m ' , $ field , $ match ) ) {
43- $ match [1 ] = preg_replace ('/(?<=^|[\x09\x20\x2D])./e ' , 'strtoupper("\0") ' , strtolower (trim ($ match [1 ])));
43+ //$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
44+ $ match [1 ] = preg_replace_callback (
45+ '/(?<=^|[\x09\x20\x2D])./ ' ,
46+ function ($ treffer ) {
47+ return strtoupper ($ treffer [0 ]);
48+ },
49+ strtolower (trim ($ match [1 ]))
50+ );
51+
4452 if ( isset ($ retVal [$ match [1 ]]) ) {
4553 if (!is_array ($ retVal [$ match [1 ]])) {
4654 $ retVal [$ match [1 ]] = array ($ retVal [$ match [1 ]]);
@@ -59,7 +67,15 @@ public static function http_parse_headers_short( $fields )
5967 $ retVal = array ();
6068 foreach ( $ fields as $ field ) {
6169 if ( preg_match ('/([^:]+): (.+)/m ' , $ field , $ match ) ) {
62- $ match [1 ] = preg_replace ('/(?<=^|[\x09\x20\x2D])./e ' , 'strtoupper("\0") ' , strtolower (trim ($ match [1 ])));
70+ ///$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
71+ $ match [1 ] = preg_replace_callback (
72+ '/(?<=^|[\x09\x20\x2D])./ ' ,
73+ function ($ treffer ) {
74+ return strtoupper ($ treffer [0 ]);
75+ },
76+ strtolower (trim ($ match [1 ]))
77+ );
78+
6379 if ( isset ($ retVal [$ match [1 ]]) ) {
6480 if (!is_array ($ retVal [$ match [1 ]])) {
6581 $ retVal [$ match [1 ]] = array ($ retVal [$ match [1 ]]);
0 commit comments