The NO_CACHE RenderParam does not appear to affect makeRequest
SHINDIG-1983
Committed For Doug Davies
git-svn-id: https://svn.apache.org/repos/asf/shindig/trunk@1632964 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/features/src/main/javascript/features/core.io/io.js b/features/src/main/javascript/features/core.io/io.js
index f305771..ad17260 100644
--- a/features/src/main/javascript/features/core.io/io.js
+++ b/features/src/main/javascript/features/core.io/io.js
@@ -462,6 +462,15 @@
'getFullHeaders': !!params['GET_FULL_HEADERS']
};
+ // add the nocache parameter if necessary
+ // request param NO_CACHE takes precedence over osapi.container.RenderParam.NO_CACHE
+
+ if (params.hasOwnProperty('NO_CACHE')) {
+ paramData['nocache'] = params['NO_CACHE'];
+ } else if (urlParams.hasOwnProperty('nocache')) {
+ paramData['nocache'] = urlParams['nocache'];
+ }
+
// OAuth goodies
if (auth === 'oauth' || auth === 'signed' || auth === 'oauth2') {
if (gadgets.io.oauthReceivedCallbackUrl_) {
@@ -648,7 +657,8 @@
'OAUTH_TOKEN_NAME',
'OAUTH_REQUEST_TOKEN',
'OAUTH_REQUEST_TOKEN_SECRET',
- 'OAUTH_RECEIVED_CALLBACK'
+ 'OAUTH_RECEIVED_CALLBACK',
+ 'NO_CACHE'
]);
/**
diff --git a/features/src/test/javascript/features/core.io/iotest.js b/features/src/test/javascript/features/core.io/iotest.js
index 3a98356..8fe8783 100644
--- a/features/src/test/javascript/features/core.io/iotest.js
+++ b/features/src/test/javascript/features/core.io/iotest.js
@@ -1291,3 +1291,73 @@
params);
this.assertEquals("not preloaded", resp.text);
};
+
+IoTest.prototype.testNoCacheOnUrlParam = function () {
+
+ this.getUrlParameters = gadgets.util.getUrlParameters;
+ gadgets.util.getUrlParameters = function () {
+ return { "st": "authtoken", "url": "http://www.gadget.com/gadget.xml", "container": "foo",
+ "nocache": "1"};
+ };
+
+ var req = new fakeXhr.Expectation("GET", "http://example.com/json");
+ this.setStandardArgs(req, false);
+ req.setQueryArg("url", "http://target.example.com/somepage");
+ req.setQueryArg("bypassSpecCache", "1");
+ req.setQueryArg("nocache", "1");
+
+ var resp = this.makeFakeResponse(
+ "{ 'http://target.example.com/somepage' : { 'body' : 'some data', 'rc' : 200 }}");
+
+ this.fakeXhrs.expect(req, resp);
+
+ var resp = null;
+ gadgets.io.makeRequest("http://target.example.com/somepage",
+ function (data) {
+ resp = data;
+ });
+ this.assertEquals('some data', resp.text);
+};
+
+IoTest.prototype.testNoCacheOnRequestParam = function () {
+
+ var req = new fakeXhr.Expectation("GET", "http://example.com/json");
+ this.setStandardArgs(req, false);
+ req.setQueryArg("url", "http://target.example.com/somepage");
+ req.setQueryArg("nocache", "1");
+
+ var resp = this.makeFakeResponse(
+ "{ 'http://target.example.com/somepage' : { 'body' : 'some data', 'rc' : 200 }}");
+
+ this.fakeXhrs.expect(req, resp);
+
+ var resp = null;
+ params = {};
+ params[gadgets.io.RequestParameters.NO_CACHE] = 1;
+ gadgets.io.makeRequest("http://target.example.com/somepage",
+ function (data) {
+ resp = data;
+ }, params);
+ this.assertEquals('some data', resp.text);
+};
+
+IoTest.prototype.testNoNoCache = function () {
+
+ var req = new fakeXhr.Expectation("GET", "http://example.com/json");
+ this.setStandardArgs(req, false);
+ req.setQueryArg("url", "http://target.example.com/somepage");
+
+ var resp = this.makeFakeResponse(
+ "{ 'http://target.example.com/somepage' : { 'body' : 'some data', 'rc' : 200 }}");
+
+ this.fakeXhrs.expect(req, resp);
+
+ var resp = null;
+ params = {};
+ gadgets.io.makeRequest("http://target.example.com/somepage",
+ function (data) {
+ resp = data;
+ }, params);
+ this.assertEquals('some data', resp.text);
+ this.assertUndefined(resp.nocache);
+};