shindig-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Campbell (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SHINDIG-1980) For caching, discriminate between requests with the same URL but different headers.
Date Mon, 30 Jun 2014 20:00:26 GMT

     [ https://issues.apache.org/jira/browse/SHINDIG-1980?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

George Campbell updated SHINDIG-1980:
-------------------------------------

    Description: 
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"
            <!-- title_url="" -->
            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}

  was:
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"
            <!-- title_url="" -->
            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);
{code}
</script>
        ]]>
        </Content>
        </Module>


> 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"
>             <!-- title_url="" -->
>             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)

Mime
View raw message