Closed Bug 658595 Opened 13 years ago Closed 3 years ago

When doing lots of Ajax requests in a short period of time custom HTTP headers (e.g. "X-Requested-With") are not sent to the server

Categories

(Core :: DOM: Core & HTML, defect, P5)

2.0 Branch
x86_64
Windows 7
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: saschakarcher, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17

Especially when FF is started new and you open an application which does lots of asynchronous ajax requests it may happen that some request gets corrupted (e.g. one out of 20).
What I'm doing is to use the XMLHttpRequest class to send an Ajax request. With the method setRequestHeader I add a custom header to the request ("X-Requested-With", "XMLHttpRequest"). 
when I send these requests rapidly some requests are sent to the server but without the custom header.
There may be a bug in the XMLHttpRequest. Because according to documentation the custom headers are dropped as soon as the send method is called. Maybe the requests aren't processes properly one after the other.....

Reproducible: Sometimes

Steps to Reproduce:
Just take a look at the demonstration site:
http://www.pixel-no1.de/dune-buggy/ff_missing_headers/

Actual Results:  
headers are dropped

Expected Results:  
all specified headers should be retained

that's all folks. 

When using the testsite I have set up please be patient. The problem may occur or not. It was really pretty random when I tested it.
Relevance:

Lots of ajax-enabled websites provide a non-ajax version of a resource (e.g. complete HTML-page with a html table containing money exchange rates) and a content only version of the resource (e.g. only the naked exchange rates in a JSON string) under the same URL. 
For server-side distinction which result to deliver to the client it is a common practive to submit a special HTTP header for Ajax requests. This HTTP header is normally named "X-Requested-With" and has the value "XMLHttpRequest". If the server sees this header it knows that the special ajax response should be delivered. If not the normal HTML page is delivered.

So the bug described here ca seriously corrupt Ajax-enabled sites.
Summary: FF sometimes drops custom headers of an Ajax request when doing lots of requests → When doing lots of Ajax requests in a short period of time custom HTTP headers (e.g. "X-Requested-With") are not sent to the server
Version: unspecified → 3.6 Branch
Component: General → DOM: Mozilla Extensions
Product: Firefox → Core
QA Contact: general → general
Version: 3.6 Branch → 2.0 Branch
Two questions:

1) Are you seeing the problem with Firefox 4?
2) What are the actual steps to reproduce?  What do I need to do with the url in
   comment 0 to show the problem?
to 1) haven't tested. but i will do....

to 2) First of all I close all instances of FF. then i open firefox and the first thing i do is go that url. Then I click the "stuff polly" button and in the textarea below you will see the word "cracker" lots of times (this is the answer from the php script which i call repeatedly via ajax/javascript. 
After some time there will be printed "leave me alone ..." instead of "cracker. This is because the php script checks whether  the HTTP header "X-Requested-With" is set. If yes it answers with "cracker". If not it answers with "leave me alone...". And this is a bug I suppose. The header isn't send sometimes, although everytinme the same ajax request is made with javascript using the XMLHttpRequest class.
I used firebug to confirm that behaviour. In firebug I can see that the header is indeed missing.
Sascha: thanks.  With those steps I ran the testcase for about 3 minutes and never got "leave me alone" with a trunk build.  Same with Firefox 4.
Tahnks Boris.
Looks like I've got a magic setup.
I will test in the office tomorrow with machines similar to mine.
I also never got "leave me alone" with Seamonkey trunk on win32.
Probably an old bug in Gecko1.9.2 that got fixed with Gecko2.0 ?
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:7.0a1) Gecko/20110621 Firefox/7.0a1

Sascha, are you still able to observe the issue? If not, can you please set the status of the bug accordingly.

Thanks!
Dupe of bug # 358352, I think. See also # 507548.

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.
Sascha, are you using proxy autodetect?

Can you test an Aurora build?  It's entirely possible that the fix for bug 553888 fixed this.
(As commented in bug 507548:)

Yes, turning off proxy autodetect fixes the issue.
Component: DOM: Mozilla Extensions → DOM
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML

The provided URL to test this can no longer be found. Closing this as resolved:incomplete. Please do re-open this issue if it is still reproducible and provide a valid testcase.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.