[OpenLayers-Dev] Sending the "X-Requested-With" header in AJAX calls

Eric Lemoine eric.lemoine at camptocamp.com
Thu Sep 8 00:24:10 EDT 2011


On Wednesday, September 7, 2011, Xavier Mamano (jorix) <
xavier.mamano at gmail.com> wrote:
> Hi,
>
> Great!
>
> But "Request.XMLHttpRequest" is not written by OpenLayers Team (see
license
> in XMLHttpRequest.js) and is fully wrapped by "Request", so I think best
> make the following change:
>
> Index: lib/OpenLayers/Request.js
> ===================================================================
> --- lib/OpenLayers/Request.js   (revision 12340)
> +++ lib/OpenLayers/Request.js   (working copy)
> @@ -122,6 +122,10 @@
>             {proxy: OpenLayers.ProxyHost}
>         );
>         config = OpenLayers.Util.applyDefaults(config, defaultConfig);
> +        config.headers = OpenLayers.Util.applyDefaults(
> +            config.headers,
> +            {"X-Requested-With": "XMLHttpRequest"}
> +        );
>
>         // create request, open, and set headers
>         var request = new OpenLayers.Request.XMLHttpRequest();
>
> This has the same effect as your proposal.


Indeed. Good catch.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20110908/05242627/attachment-0001.html


More information about the Dev mailing list