Skip to content

Commit

Permalink
The NO_CACHE RenderParam does not appear to affect makeRequest
Browse files Browse the repository at this point in the history
SHINDIG-1983
Committed For Doug Davies

git-svn-id: https://svn.apache.org/repos/asf/shindig/trunk@1632964 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ryanjbaxter committed Oct 19, 2014
1 parent d8c7d05 commit 1f96115
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
12 changes: 11 additions & 1 deletion features/src/main/javascript/features/core.io/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,15 @@ gadgets.io = function() {
'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_) {
Expand Down Expand Up @@ -648,7 +657,8 @@ gadgets.io.RequestParameters = gadgets.util.makeEnum([
'OAUTH_TOKEN_NAME',
'OAUTH_REQUEST_TOKEN',
'OAUTH_REQUEST_TOKEN_SECRET',
'OAUTH_RECEIVED_CALLBACK'
'OAUTH_RECEIVED_CALLBACK',
'NO_CACHE'
]);

/**
Expand Down
70 changes: 70 additions & 0 deletions features/src/test/javascript/features/core.io/iotest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,3 +1291,73 @@ IoTest.prototype.testPreload_oauthApproval = function() {
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);
};

0 comments on commit 1f96115

Please sign in to comment.