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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jgotts at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Dec 22 11:01:30 2024 UTC