note 116343 added to function.apache-request-headers

From: Date: Tue, 16 Dec 2014 09:22:05 +0000
Subject: note 116343 added to function.apache-request-headers
Groups: php.notes 
Request: Send a blank email to php-notes+get-201201@lists.php.net to get a copy of this message
A slightly modified version from limalopex.eisfux.de. Fixes the missing Headers Content-Type and Content-Length and makes it Camel-Case. <?php if( !function_exists('apache_request_headers') ) { function apache_request_headers() { $arh = array(); $rx_http = '/\AHTTP_/'; foreach($_SERVER as $key => $val) { if( preg_match($rx_http, $key) ) { $arh_key = preg_replace($rx_http, '', $key); $rx_matches = array(); // do some nasty string manipulations to restore the original letter case // this should work in most cases $rx_matches = explode('_', strtolower($arh_key)); if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val); $arh_key = implode('-', $rx_matches); } $arh[$arh_key] = $val; } } if(isset($_SERVER['CONTENT_TYPE'])) $arh['Content-Type'] = $_SERVER['CONTENT_TYPE']; if(isset($_SERVER['CONTENT_LENGTH'])) $arh['Content-Length'] = $_SERVER['CONTENT_LENGTH']; return( $arh ); } } ---- Server IP: 213.172.110.14 Probable Submitter: 94.186.137.245 ---- Manual Page -- http://php.net/manual/en/function.apache-request-headers.php Edit -- https://master.php.net/note/edit/116343 Del: integrated -- https://master.php.net/note/delete/116343/integrated Del: useless -- https://master.php.net/note/delete/116343/useless Del: bad code -- https://master.php.net/note/delete/116343/bad+code Del: spam -- https://master.php.net/note/delete/116343/spam Del: non-english -- https://master.php.net/note/delete/116343/non-english Del: in docs -- https://master.php.net/note/delete/116343/in+docs Del: other reasons-- https://master.php.net/note/delete/116343 Reject -- https://master.php.net/note/reject/116343 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201201) next »