From 32fbeaeca57ef682ed3306ea7eb50a899c6018ee Mon Sep 17 00:00:00 2001 From: Photodeus Date: Sun, 20 Sep 2009 16:04:43 -0700 Subject: [PATCH 1/3] POST request should have a Content-Type header. http://github.com/greasemonkey/greasemonkey/issues/#issue/1032 --- content/xmlhttprequester.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/xmlhttprequester.js b/content/xmlhttprequester.js index 74d6dac21..ca45bc66e 100644 --- a/content/xmlhttprequester.js +++ b/content/xmlhttprequester.js @@ -69,11 +69,17 @@ GM_xmlhttpRequester.prototype.chromeStartRequest = function(safeUrl, details) { req.overrideMimeType(details.overrideMimeType); } + var contentTypeSet = false; if (details.headers) { for (var prop in details.headers) { req.setRequestHeader(prop, details.headers[prop]); + if (prop.toLowerCase() == "content-type") contentTypeSet = true; } } + // If request method is POST, the content type needs to be set for it to work as expected + if (req.method.toUpperCase() == "POST" && !contentTypeSet) { + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + } req.send((details.data) ? details.data : null); GM_log("< GM_xmlhttpRequest.chromeStartRequest"); From 3d0183af0f364cce7e820be59e1fbb363219cb67 Mon Sep 17 00:00:00 2001 From: Photodeus Date: Mon, 21 Sep 2009 06:05:45 -0700 Subject: [PATCH 2/3] details.method instead of req.method --- content/xmlhttprequester.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/xmlhttprequester.js b/content/xmlhttprequester.js index ca45bc66e..1a5c8c4a2 100644 --- a/content/xmlhttprequester.js +++ b/content/xmlhttprequester.js @@ -77,7 +77,7 @@ GM_xmlhttpRequester.prototype.chromeStartRequest = function(safeUrl, details) { } } // If request method is POST, the content type needs to be set for it to work as expected - if (req.method.toUpperCase() == "POST" && !contentTypeSet) { + if (details.method.toUpperCase() == "POST" && !contentTypeSet) { req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } From 4ecdc69cf0194e4187f889e0cc27eefce98f6d9f Mon Sep 17 00:00:00 2001 From: "Seppo J. Vuolteenaho" Date: Thu, 22 Nov 2012 23:41:31 +0100 Subject: [PATCH 3/3] Add filename and line number to warning "return-not-in-func-deprecated" --- components/greasemonkey.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/greasemonkey.js b/components/greasemonkey.js index 90b9fc73e..89d157553 100644 --- a/components/greasemonkey.js +++ b/components/greasemonkey.js @@ -292,7 +292,9 @@ function runScriptInSandbox(script, sandbox) { // not in a function. GM_util.logError( gStringBundle.GetStringFromName('return-not-in-func-deprecated'), - true // is a warning + true, // is a warning + fileName, + e.lineNumber ); Components.utils.evalInSandbox( GM_util.anonWrap(code), sandbox, gMaxJSVersion, fileName, 1);