Skip to content

Commit 6c124d3

Browse files
committed
Fixes #8423. Never set X-Requested-With header automagically for cross-domain requests.
1 parent 2d0bc7c commit 6c124d3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ajax/xhr.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ if ( jQuery.support.ajax ) {
9292
xhr.overrideMimeType( s.mimeType );
9393
}
9494

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

0 commit comments

Comments
 (0)