Closed Bug 929760 Opened 7 years ago Closed 7 years ago

XMLHttpRequest setRequestHeader() skips blank headers

Categories

(Core :: Networking: HTTP, defect)

24 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 815299

People

(Reporter: jgotts, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0 (Beta/Release)
Build ID: 20130917102605

Steps to reproduce:

During the development of our application, which runs under Firefox, we thought it would be a good idea to send a blank header for development purposes. This header doesn't make it through.

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

Here's a curl script that does the same thing:

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] => 
)


Actual results:

Array
(
    ...
    [my-header] => 
)

is missing.


Expected results:

Array
(
    ...
    [my-header] => 
)
Hm, we are removing the header if the header value is empty,
https://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpHeaderArray.cpp?rev=aceb8d1e6eba#18
But it doesn't comply with the spec.
http://xhr.spec.whatwg.org/#the-setrequestheader%28%29-method
> Note: An empty string represents an empty header field value.
Component: General → Networking: HTTP
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 815299
You need to log in before you can comment on or make changes to this bug.