Side navigation
#384 closed bug (worksforme)
Opened November 12, 2006 06:26PM UTC
Closed August 19, 2007 09:06PM UTC
Last modified March 14, 2012 10:50PM UTC
IE fails to send/set custom request headers
Reported by: | choan.galvez@gmail.c | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1.4 |
Component: | ajax | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It'd be nice to allow custom request headers in AJAX requests.
Here is a patch:
Index: src/ajax/ajax.js =================================================================== --- src/ajax/ajax.js (revision 569) +++ src/ajax/ajax.js (working copy) @@ -710,6 +710,7 @@ dataType: null, data: null, url: null, + headers: {} }, s); // if data available @@ -746,6 +747,10 @@ // Set header so the called script knows that it's an XMLHttpRequest xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); + + jQuery.each(s.headers, function(i) { + xml.setRequestHeader(i, this); + }); // Make sure the browser sends the right content length if ( xml.overrideMimeType )
Attachments (0)
Change History (15)
Changed November 12, 2006 11:43PM UTC by comment:1
component: | ajax |
---|---|
keywords: | request, ajax, headers → request, |
owner: | john |
priority: | minor |
summary: | Allow custom request headers in AJAX requests → Allow |
type: | feature |
Changed November 13, 2006 01:35AM UTC by comment:2
component: | → ajax |
---|---|
keywords: | request, → request, ajax, headers |
owner: | → john |
priority: | → major |
summary: | Allow → Allow custom request headers |
type: | → enhancement |
Changed November 13, 2006 08:45AM UTC by comment:3
milestone: | → 1.1 |
---|---|
version: | → 1.1 |
Changed November 15, 2006 05:34AM UTC by comment:4
component: | ajax |
---|---|
keywords: | request, ajax, headers → request, |
milestone: | 1.1 |
owner: | john |
priority: | major |
summary: | Allow custom request headers → Allow |
type: | enhancement |
version: | 1.1 |
Nice gusetbook! |
Changed November 17, 2006 03:10AM UTC by comment:5
Nice gusetbook! |
Changed November 19, 2006 01:35AM UTC by comment:6
Nice gusetbook! |
Changed November 21, 2006 08:05AM UTC by comment:7
Nice gusetbook! |
Changed November 24, 2006 02:51AM UTC by comment:8
Nklikital Nice |
Changed December 04, 2006 05:05PM UTC by comment:9
I'd like to vote for the inclusion of this into jQuery ASAP.
Changed December 04, 2006 07:39PM UTC by comment:10
component: | → ajax |
---|---|
keywords: | request, |
milestone: | → 1.1 |
owner: | → john |
priority: | → major |
summary: | Allow → IE fails to send/set custom request headers |
type: | → bug |
version: | → 1.1 |
There is now a "preprocess" option for $.ajax that allows to set both custom headers and override mimeTypes. IE (5 - 7) seems to fail to set/send custom headers, therefore I leave this ticket open until a solution or explanation is found for that issue.
Changed December 04, 2006 07:41PM UTC by comment:11
Renamed "preprocess" to "before" for consistency with form plugin.
Changed December 11, 2006 09:12AM UTC by comment:12
The callback is now "beforeSend".
The tests still fail for IE. Using a pseudo-standard header starting with "X-..." doesn't help either.
Changed December 21, 2006 03:24PM UTC by comment:13
resolution: | → fixed |
---|---|
status: | new → closed |
Seems like this is only a problem in the testsuite, as noone else is reporting this problem.
Changed March 27, 2007 09:42PM UTC by comment:14
resolution: | fixed |
---|---|
status: | closed → reopened |
I'm currently having the same problem in FF.
the 'X-Requested-With' header which should be built-in to jQuery is not being sent with the request.
I've checked every line of the code and I'm certain the following lines get executed:
1998 Set header so the called script knows that it's an XMLHttpRequest
1999 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
I've also tried my own implementation...
Add custom header to every call (HTTP_X_METHOD:Ajax)
$().ajaxSend(function(a,r,o){ r.setRequestHeader("X-Method", "Ajax"); });
But this also fails...
Changed August 19, 2007 09:06PM UTC by comment:15
description: | It'd be nice to allow custom request headers in AJAX requests.\ \ Here is a patch:\ \ {{{\ Index: src/ajax/ajax.js\ ===================================================================\ --- src/ajax/ajax.js (revision 569)\ +++ src/ajax/ajax.js (working copy)\ @@ -710,6 +710,7 @@\ dataType: null,\ data: null,\ url: null,\ + headers: {}\ }, s);\ \ // if data available\ @@ -746,6 +747,10 @@\ \ // Set header so the called script knows that it's an XMLHttpRequest\ xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");\ + \ + jQuery.each(s.headers, function(i) {\ + xml.setRequestHeader(i, this);\ + });\ \ // Make sure the browser sends the right content length\ if ( xml.overrideMimeType )\ \ }}} → It'd be nice to allow custom request headers in AJAX requests. \ \ Here is a patch: \ \ {{{ \ Index: src/ajax/ajax.js \ =================================================================== \ --- src/ajax/ajax.js (revision 569) \ +++ src/ajax/ajax.js (working copy) \ @@ -710,6 +710,7 @@ \ dataType: null, \ data: null, \ url: null, \ + headers: {} \ }, s); \ \ // if data available \ @@ -746,6 +747,10 @@ \ \ // Set header so the called script knows that it's an XMLHttpRequest \ xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); \ + \ + jQuery.each(s.headers, function(i) { \ + xml.setRequestHeader(i, this); \ + }); \ \ // Make sure the browser sends the right content length \ if ( xml.overrideMimeType ) \ \ }}} |
---|---|
milestone: | 1.1a → 1.1.4 |
need: | → Review |
resolution: | → worksforme |
status: | reopened → closed |
version: | 1.1a → 1.1.3 |
iam we! |