Closed Bug 129109 Opened 23 years ago Closed 23 years ago

XMLHttpRequest abort() partially implemented

Categories

(Core :: XML, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: hjtoi-bugzilla, Assigned: hjtoi-bugzilla)

Details

(Keywords: topembed, Whiteboard: [DIGbug])

Attachments

(1 file)

This used to be Bugscape bug 12317. XMLHttpRequest has two abort() functions (one from its own interface and callable from JS) and the other from doc load listener interface. There are two channels: one for uploading and one for downloading. Currently only one abort() cancels only the download channel. Will attach a patch that fixes this.
Status: NEW → ASSIGNED
Keywords: nsbeta1+, topembed
Priority: -- → P2
Whiteboard: [DIGbug][fixinhand]
Target Milestone: --- → mozilla1.0
Comment on attachment 72634 [details] [diff] [review] Fix r=harishd sr=darin
Attachment #72634 - Flags: superreview+
Attachment #72634 - Flags: review+
And here is more description of the problem with a testcase. THE PROBLEM If I send an http request to a server, the server never gets notified that the socket is closed when I call abort() or when I refresh the page. The only time the socket is closed is when I close the last browser window. EXAMPLE CODE Here is an example page and the associated javascript file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Testing xml communicator</title> <script src="test.js"></script> </head> <body> <h1>Testing xml communicator</h1> <a href="javascript:create()">Start Request</a> <br> <br> <a href="javascript:abort()">Abort Request</a> <hr> </body> </html> here is test.js: var hostURL = "http://aladdin:3939"; var ua = navigator.userAgent.toLowerCase(); var isIE = (ua.indexOf('msie') != -1); create = function() { if ( ! isIE) { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } window.requestor = (isIE) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); window.requestor.open("POST", hostURL, true); window.requestor.send("a test"); } abort = function() { if (window.requestor) { window.requestor.abort(); } } POSSIBLE WORKAROUND The only workaround I can think of is to have some gecko-specific code on the server and the client that depends on a periodic heart-beat being sent to the server. The downside is that this is going to consume extra resources on the server to handle all these extra http requests (the current system supports 60,000 sessions per server).
Comment on attachment 72634 [details] [diff] [review] Fix a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #72634 - Flags: approval+
Checked in. I don't think abort() will be automatically called if you refresh the page, but I believe you can achieve that by calling abort() from the onunload handler of the page.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Whiteboard: [DIGbug][fixinhand] → [DIGbug]
That sounds fine. Thanks!
I tested this on trunk build 20020312 and it is working great.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: