You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@shindig.apache.org by Jasha Joachimsthal <j....@onehippo.com> on 2011/11/05 12:36:45 UTC

Make request with accept header

Hi,

my gadget needs to fetch (XML) data from a server that requires an "Accept"
header with "application/xml".
I've set this header in my makeDOMRequest function:

function makeDOMRequest() {
    var params = {};
    params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.DOM;
    params[gadgets.io.RequestParameters.HEADERS] =
{"Accept":"application/xml"};
    gadgets.io.makeRequest(url, response, params);
  }

This function is called
by gadgets.util.registerOnLoadHandler(makeDOMRequest);

There is a function response(obj) that should create nice HTML from obj.
However obj.domdata is undefined.

DefaultRequestPipeline#execute is called twice. The first time the request
object doesn't have the request header "Accept: application/xml". The
second time it's called from MakeRequestHandler and with the correct header
in the request object. The second time the request isn't really executed
but its response is fetched from cache. The cache contains an empty
response body because the first request didn't send the header.

Is this a bug in Shindig or is there a way to make this work? I'm using
Shindig 3.0.0-beta2.


Jasha Joachimsthal

Europe - Amsterdam - Oosteinde 11, 1017 WT Amsterdam - +31(0)20 522 4466
US - Boston - 1 Broadway, Cambridge, MA 02142 - +1 877 414 4776 (toll free)

www.onehippo.com

Re: Make request with accept header

Posted by Jasha Joachimsthal <j....@onehippo.com>.
Never mind, after some further debugging I found out the real issue was in
the script of my gadget, not in the makerequest handling

obj.domdata should be obj.data




On 5 November 2011 12:36, Jasha Joachimsthal <j....@onehippo.com>wrote:

> Hi,
>
> my gadget needs to fetch (XML) data from a server that requires an
> "Accept" header with "application/xml".
> I've set this header in my makeDOMRequest function:
>
> function makeDOMRequest() {
>     var params = {};
>     params[gadgets.io.RequestParameters.CONTENT_TYPE] =
> gadgets.io.ContentType.DOM;
>     params[gadgets.io.RequestParameters.HEADERS] =
> {"Accept":"application/xml"};
>     gadgets.io.makeRequest(url, response, params);
>   }
>
> This function is called
> by gadgets.util.registerOnLoadHandler(makeDOMRequest);
>
> There is a function response(obj) that should create nice HTML from obj.
> However obj.domdata is undefined.
>
> DefaultRequestPipeline#execute is called twice. The first time the request
> object doesn't have the request header "Accept: application/xml". The
> second time it's called from MakeRequestHandler and with the correct header
> in the request object. The second time the request isn't really executed
> but its response is fetched from cache. The cache contains an empty
> response body because the first request didn't send the header.
>
> Is this a bug in Shindig or is there a way to make this work? I'm using
> Shindig 3.0.0-beta2.
>
>
> Jasha Joachimsthal
>
> Europe - Amsterdam - Oosteinde 11, 1017 WT Amsterdam - +31(0)20 522 4466
> US - Boston - 1 Broadway, Cambridge, MA 02142 - +1 877 414 4776 (toll
> free)
>
> www.onehippo.com
>