[ 
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="campb...@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>

  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="WMS List Maker"
            
title_url="https://dl.dropboxusercontent.com/u/8515698/opensocial/gadget.xml";
            description="Scan item barcodes and generate exportable lists of 
item metadata."
            author="OCLC"
            author_email="dev...@oclc.org"
            
thumbnail="https://dl.dropboxusercontent.com/u/8515698/opensocial/images/wmsListMakerScreenShot.png";
            width="1000"
            height="700"
            lang="en"
            country="us">
        <link rel="preview" 
href="https://dl.dropboxusercontent.com/u/8515698/opensocial/images/wmsListMakerThumbnail.png"/>
        <OAuth2>
            <Service name="oclcAPI" scope="shindig_WMS_ACQ"></Service>
        </OAuth2>
        <Require feature="opensocial-2.5"/>
        <Require feature="oauthpopup"/>
    </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="campb...@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>



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to