php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65943 Blank headers missing with apache_request_headers
Submitted: 2013-10-22 01:48 UTC Modified: 2013-10-22 22:37 UTC
From: jgotts at gmail dot com Assigned:
Status: Closed Package: Apache related
PHP Version: 5.4.21 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 + 32 = ?
Subscribe to this entry?

 
 [2013-10-22 01:48 UTC] jgotts at gmail dot com
Description:
------------
It appears that apache_request_headers won't return blank headers. The key for said header is missing from the associative array. We have something quite simple on the JavaScript side:

var xhr = new XMLHttpRequest();
...
xhr.setRequestHeader('my-header', '');

Nothing in https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest disallows a blank second argument for setRequestHeader().

And on the PHP side, we have:

$headers = apache_request_headers();

$headers['my-header'] is missing! What ate it?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-22 22:37 UTC] jgotts at gmail dot com
-Status: Open +Status: Closed
 [2013-10-22 22:37 UTC] jgotts at gmail dot com
I'm going to close this bug because it's a bug in XMLHttpRequest::setRequestHeader() in Firefox 24, not in PHP.

PHP does the right thing when I explicitly set a blank header like this:

curl -k -H "my-header;" https://127.0.0.1/test.php

test.php:

<?php

print_r(apache_request_headers());

?>

Output:

Array
(
    [User-Agent] => curl/7.27.0
    [Host] => 127.0.0.1
    [Accept] => */*
    [my-header] => 
)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC