Skip to content

Commit

Permalink
Fixes #8423. Never set X-Requested-With header automagically for cros…
Browse files Browse the repository at this point in the history
…s-domain requests.
  • Loading branch information
jaubourg committed Mar 6, 2011
1 parent 2d0bc7c commit 6c124d3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ajax/xhr.js
Expand Up @@ -92,11 +92,12 @@ if ( jQuery.support.ajax ) {
xhr.overrideMimeType( s.mimeType );
}

// Requested-With header
// Not set for crossDomain requests with no content
// (see why at http://trac.dojotoolkit.org/ticket/9486)
// Won't change header if already provided
if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !s.crossDomain && !headers["X-Requested-With"] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}

Expand Down

0 comments on commit 6c124d3

Please sign in to comment.