|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-17 09:45 UTC] s dot kang at traviangames dot com
Description: ------------ Hi, the HttpRequest::getHeaders() method returns an associative array, which cannot be accessed normally. See code sample. The php -i output for pecl_http: HTTP Support => enabled Extension Version => 1.7.1 Registered Classes => HttpUtil, HttpMessage, HttpRequest, HttpRequestPool, HttpRequestDataShare, HttpDeflateStream, HttpInflateStream, HttpResponse, HttpQueryString Output Handlers => ob_deflatehandler, ob_inflatehandler, ob_etaghandler Stream Filters => http.chunked_decode, http.chunked_encode, http.deflate, http.inflate Used Library => Compiled => Linked libcurl => 7.21.3 => 7.21.3 libevent => 1.4 or greater => 1.4.12-stable libz => 1.2.3.4 => 1.2.3.4 libmagic => disabled => disabled Test script: --------------- /* @var $req \HttpRequest */ $headers = (array)$req->getHeaders(); var_export($headers['Accept']); // Undefined index: Accept array_key_exists('Accept', $headers); // false $headers = unserialize(serialize($headers)); array_key_exists('Accept', $headers); // true Expected result: ---------------- Script should display the contents of Accept header e.g. array(0 => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') first array_key_exists should yield true Actual result: -------------- Undefined index: Accept false PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 15:00:01 2025 UTC |
After further investigation the wrongly provided headers are not the cause of the experienced bug. $headers = array( 'X-Test' => 'test' ); $req = new HttpRequest(); $req->setHeaders($headers); array_key_exists('X-Test', $req->getHeaders()); // false