You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Ryan Baxter (JIRA)" <ji...@apache.org> on 2014/07/01 15:26:24 UTC
[jira] [Commented] (SHINDIG-1980) For caching, discriminate between
requests with the same URL but different headers.
[ https://issues.apache.org/jira/browse/SHINDIG-1980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14048863#comment-14048863 ]
Ryan Baxter commented on SHINDIG-1980:
--------------------------------------
Hi George,
Thanks for the bug. I don't think any headers are taken into account in the default cache implementation. I believe AbstractHttpCache.createKey is the culprit. Do you have any interest in providing a patch to fix this?
> For caching, discriminate between requests with the same URL but different headers.
> -----------------------------------------------------------------------------------
>
> Key: SHINDIG-1980
> URL: https://issues.apache.org/jira/browse/SHINDIG-1980
> Project: Shindig
> Issue Type: Bug
> Components: Java
> Reporter: George Campbell
> Priority: Minor
>
> If a gadgets.io.makeRequest is made with a header of:
> {code}{'accept': ['text/xml']}{code}
> but the REFRESH_VALUE is left at its default value of 3600 seconds, XML is returned and the request is cached (as it should be). However, if another request with the same URL is made with a different header, say:
> {code}{'accept': ['application/json']}{code}
> then the cached XML response is still returned. The caching is not taking into account the different headers and considers the requests to be the same, although they are very different.
> Here's a sample gadget:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- https://dl.dropboxusercontent.com/u/8515698/opensocial/gadget.xml -->
> <Module>
> <ModulePrefs
> title="VIAF request from OCLC"
> description="Simple VIAF request demonstrating XML and JSON return results."
> author="OCLC"
> author_email="campbelg@oclc.org"
> width="1000"
> height="700"
> lang="en"
> country="us">
> <Require feature="opensocial-2.5"/>
> </ModulePrefs>
> <Content type="html" view="default">
> <![CDATA[
> var url = encodeURI('http://www.viaf.org/viaf/search?query=cql.any all "jane austen"&recordLimit=1'),
> params = {};
> params[gadgets.io.RequestParameters.GET_FULL_HEADERS] = true;
> params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.NONE;
> params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
> params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
> params[gadgets.io.RequestParameters.HEADERS] = {
> accept: [ "text/xml" ] // switch to "application/json" and try it again!
> };
> gadgets.io.makeRequest(url, function (data) {
> gadgets.log("/~~/~~/~~/~~/~~/~~/~~ BEGIN gadets.io TEST /~~/~~/~~/~~/~~/~~/~~/~~");
> gadgets.log("REQUEST TYPE - accept:" + params[gadgets.io.RequestParameters.HEADERS]["accept"]);
> gadgets.log("response code: " + data.rc);
> gadgets.log("header: content-type:" + data.headers["content-type"][0]);
> gadgets.log("response data:");
> gadgets.log(data.data.substr(0, 1e3));
> }, params);
> </script>
> ]]>
> </Content>
> </Module>
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)