Uploaded image for project: 'Shindig'
  1. Shindig
  2. SHINDIG-1980

For caching, discriminate between requests with the same URL but different headers.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Java
    • None

    Description

      If a gadgets.io.makeRequest is made with a header of:

      {'accept': ['text/xml']}

      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:

      {'accept': ['application/json']}

      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:

      <?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>
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            campbelg George Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: