Closed
Bug 507548
Opened 16 years ago
Closed 8 years ago
XMLHttpRequest.setRequestHeader doesn't add header to HTTP request randomly
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: morgan.chengmo, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.37 Safari/530.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)
The javascript XMLHttpRequest objects setRequestHeader("X-EventHandler"","1") method doesn't add one "X-EventHandler" header to HTTP request.
Reproducible: Sometimes
Steps to Reproduce:
1. Write a script like below to repeatedly send XMLHttpRequest with setRequestHeader to a URI that echo back the custom HTTP header.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<div>
show something v11
</div>
<div id="divDisplay"></div>
<script>
function ping() {
var oXHR = new XMLHttpRequest();
var sUri = "/EchoRequestHeader.aspx";
oXHR.open("GET", sUri, true);
oXHR.setRequestHeader("X-EventHandler", 1);
oXHR.onreadystatechange = function() {
if (oXHR.readyState == 4)
{
if (oXHR.responseText.indexOf("X-EventHandler") == -1)
{
alert("no xheader");
clearInterval(hd);
}
}
else
{
//alert(oXHR.readyState);
}
var divDis = document.getElementById("divDisplay");
if (oXHR.readyState == 4)
{
divDis.textContent = ""+(new Date());
divDis.innerText = ""+(new Date());
}
}
oXHR.send(null);
}
var hd = setInterval(ping, 200);
</script>
</body>
</html>
2. Write a server side page to simply echo back "X-EventHandler" if available.
3. Run the script against the echo URI.
Actual Results:
Sometimes and randomly, the HTTP request doesn't have custom "X-EventHandler" header.
Expected Results:
XMLHttpRequest.setRequestHeader should always add one HTTP request header if given header is not there.
All add-on and plug-in are disabled, and it still repro.
The firefox.exe file version is 1.9.1.3483. Its size is 908280 bytes.
We have installations with same version that repro frequently and not repro at all. It is random.
Reporter | ||
Comment 1•16 years ago
|
||
Update repro script. Ignore response without 200 status code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<div>
show something v11
</div>
<div id="divDisplay"></div>
<script>
function ping() {
var oXHR = new XMLHttpRequest();
var sUri = "/EchoRequestHeader.aspx";
oXHR.open("GET", sUri, true);
oXHR.setRequestHeader("X-EventHandler", 1);
oXHR.onreadystatechange = function() {
if (oXHR.readyState == 4)
{
if (oXHR.status != 200) return;
if (oXHR.responseText.indexOf("X-EventHandler") == -1)
{
alert("no xheader");
clearInterval(hd);
}
}
else
{
//alert(oXHR.readyState);
}
var divDis = document.getElementById("divDisplay");
if (oXHR.readyState == 4)
{
divDis.textContent = ""+(new Date());
divDis.innerText = ""+(new Date());
}
}
oXHR.send(null);
}
var hd = setInterval(ping, 200);
</script>
</body>
</html>
![]() |
||
Comment 2•15 years ago
|
||
Is this still an issue with Firefox 3.6?
Reporter | ||
Comment 3•15 years ago
|
||
(In reply to comment #2)
> Is this still an issue with Firefox 3.6?
This issue can only repro in some installation.
I checked in my Firefox 3.6 installation, it doesn't repro. However, it doesn't guarantee that this issue is gone.
![]() |
||
Comment 4•15 years ago
|
||
Ok. Is there something the installations of 3.5 where this is reproducible have in common? Some extension (Firebug, say?) installed in all of them, or something?
Reporter | ||
Comment 5•15 years ago
|
||
There are 3 users in my group have FF3.5 installation repro this issue. There is no obvious common behavior for the repro. One of them has fresh installation without any Add-ons.
Till now, I haven't get any repro report from FF3.6.
![]() |
||
Comment 6•15 years ago
|
||
That's really odd. I've been auditing the relevant codepath, and I just don't see a way this could reasonably happen as long as I assume that the RAM isn't randomly flipping boolean values and such.
Comment 7•14 years ago
|
||
Dupe of bug # 358352, I think.
Happens to me constantly while developing, admittedly with Firebug installed. In these cases, the request will spawn _two_ actual requests, one of them being OK, the other missing the X-Requested-With header.
Has been happening since 3.x, still happening in 5.0 with latest Firebug.
![]() |
||
Comment 8•14 years ago
|
||
> In these cases, the request will spawn _two_ actual requests
Interesting. Are you using proxy autodetect? What about Morgan?
Can you test an Aurora build? It's entirely possible that the fix for bug 553888 fixed this.
Comment 9•14 years ago
|
||
Turning off proxy autodetect definitely seems to fix the issue -- thank you!
Not only that, but AJAX requests are now really, really fast; they were taking 2-3 seconds each (regardless of the backend time) previously, and now they're back to speeds that I see with other browsers.
![]() |
||
Comment 10•14 years ago
|
||
Yeah, in that case bug 553888 should fix things for you. Would you mind filing a separate bug on the performance issue with proxy autodetect and ccing me on that?
Comment 11•14 years ago
|
||
I may well have jumped the gun on that one. I am not able to reproduce the slowness with FF5 and proxy autodetect enabled at the moment. I will file a bug report if I'm able to reproduce it.
Thanks!
Updated•8 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•