Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

GM_xmlhttpRequest really needs a synchronous mode. #1269

Closed
wants to merge 7 commits into from

4 participants

@meh

Shouldn't be a problem to merge to master.

Or reimplement it in some other way, this was just a fast hack to get something I needed working.

Thanks.

@meh

Eh, obvious security bugs, didn't read the setupRequestEvent properly.

There shouldn't be security issues now.

@erikvold

why is a synchronous mode needed? it's a terrible thing to do..

@meh

Because asynchronous requests aren't always the best way, and I don't see why not giving the developer the chance to use synchronous requests.

@erikvold

Because asynchronous requests aren't always the best way

when is it not?

@meh

In my case I had to try multiple lyrics website one after another if the previous failed, and setting up it to work with asynchronous requests would be an useless overengineering when there's synchronous mode.

@erikvold

In my case I had to try multiple lyrics website one after another if the previous failed, and setting up it to work with asynchronous requests would be an useless overengineering when there's synchronous mode.

It's not useless.. synchronous xhr locks the ui, asynchronous requests do not lock the ui..

@meh

It doesn't lock the UI for me.

And once again, leave the choice to the developer.

@na-ji

That right, the possibility to have a synchronous mode for the function GM_xmlhttprequest will really help the developers. In some case, it can be very usefull.

That why as meh said, leave the choice to the developer is a great solution.

Thanks.

@meh meh Merge remote-tracking branch 'upstream/master'
Conflicts:
	content/xmlhttprequester.js
ab11a1b
@arantius arantius referenced this pull request from a commit in arantius/greasemonkey
@arantius arantius Merge commit '51e17b7c703c75c074811a57e230690ef2fc077d'
Conflicts:
	content/xmlhttprequester.js

Fixes: #1269
0478edb
@arantius arantius closed this
@arantius
Collaborator

In at least some circumstances, this is currently failing with
Error: Permission denied for <http://arantius.com> to get property Object.status
Source File: file:///.../gm_scripts/sync_gm_xhr_test/sync_gm_xhr_test.user.js
Line: 14

Though I'm sure I saw it work at least once, also.
Currently testing in: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18

Test case: https://gist.github.com/1134362

@arantius arantius reopened this
@arantius
Collaborator

Working on Mozilla/5.0 (X11; Linux i686 on x86_64; rv:7.0a2) Gecko/20110809 Firefox/7.0a2.

@arantius
Collaborator

Also working: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1.

So, failing in 3 only, working in 4+.

@arantius arantius closed this pull request from a commit
@arantius arantius Don't use getters for synchronous request return values.
The request was synchronous, so the values are available now anyway.  Works with Firefox 3.6 as well as 4+.

Fixes #1269
c12141c
@arantius arantius closed this in c12141c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 28, 2011
  1. @meh
  2. @meh

    Obvious security fixes.

    meh authored
Commits on Mar 14, 2011
  1. @meh
Commits on Mar 26, 2011
  1. @meh
Commits on Apr 4, 2011
  1. @meh
Commits on Apr 5, 2011
  1. @meh
Commits on May 18, 2011
  1. @meh

    Merge remote-tracking branch 'upstream/master'

    meh authored
    Conflicts:
    	content/xmlhttprequester.js
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 4 deletions.
  1. +13 −4 content/xmlhttprequester.js
View
17 content/xmlhttprequester.js
@@ -40,9 +40,14 @@ GM_xmlhttpRequester.prototype.contentStartRequest = function(details) {
}
return {
- abort: function() {
- req.abort();
- }
+ get responseText() req.responseText,
+ get responseHeaders() req.getAllResponseHeaders(),
+ get readyState() req.readyState,
+ get status() req.status,
+ get statusText() req.statusText,
+ get finalUrl() req.channel.URI.spec,
+
+ abort: function () req.abort()
};
};
@@ -59,7 +64,7 @@ function(safeUrl, details, req) {
req.mozBackgroundRequest = !!details.mozBackgroundRequest;
- req.open(details.method, safeUrl, true, details.user || "", details.password || "");
+ req.open(details.method, safeUrl, !details.synchronous, details.user || "", details.password || "");
if (details.overrideMimeType) {
req.overrideMimeType(details.overrideMimeType);
@@ -81,6 +86,10 @@ function(safeUrl, details, req) {
} else {
req.send(body);
}
+
+ GM_log("< GM_xmlhttpRequest.chromeStartRequest");
+
+ return req;
};
// sets the "Referer" HTTP header for this GM_XHR request.
Something went wrong with that request. Please try again.