git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1130beb
)
Make sure that requests without a body don't set contentType, and a zero-length body...
author
Dave Methvin
<dave.methvin@gmail.com>
Fri, 24 Sep 2010 21:56:03 +0000
(17:56 -0400)
committer
jeresig
<jeresig@gmail.com>
Fri, 24 Sep 2010 21:56:03 +0000
(17:56 -0400)
src/ajax.js
patch
|
blob
|
history
diff --git
a/src/ajax.js
b/src/ajax.js
index
baf7ae8
..
ef0e1d8
100644
(file)
--- a/
src/ajax.js
+++ b/
src/ajax.js
@@
-4,6
+4,7
@@
var jsc = jQuery.now(),
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rselectTextarea = /^(?:select|textarea)/i,
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rselectTextarea = /^(?:select|textarea)/i,
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ rnoContent = /^(?:GET|HEAD|DELETE)$/,
rbracket = /\[\]$/,
jsre = /\=\?(&|$)/,
rquery = /\?/,
rbracket = /\[\]$/,
jsre = /\=\?(&|$)/,
rquery = /\?/,
@@
-204,7
+205,7
@@
jQuery.extend({
ajax: function( origSettings ) {
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
ajax: function( origSettings ) {
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
- jsonp, status, data, type = s.type.toUpperCase();
+ jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type);
s.url = s.url.replace( rhash, "" );
s.url = s.url.replace( rhash, "" );
@@
-355,8
+356,8
@@
jQuery.extend({
// Need an extra try/catch for cross domain requests in Firefox 3
try {
// Need an extra try/catch for cross domain requests in Firefox 3
try {
- // Set the correct header, if data is being sent
- if ( s.data || origSettings && origSettings.contentType ) {
+ // Set content-type if data specified and content-body is valid for this type
+ if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) {
xhr.setRequestHeader("Content-Type", s.contentType);
}
xhr.setRequestHeader("Content-Type", s.contentType);
}
@@
-491,7
+492,7
@@
jQuery.extend({
// Send the data
try {
// Send the data
try {
- xhr.send( (type !== "GET" && s.data) || null );
+ xhr.send( noContent || s.data == null ? null : s.data );
} catch( sendError ) {
jQuery.ajax.handleError( s, xhr, null, sendError );
} catch( sendError ) {
jQuery.ajax.handleError( s, xhr, null, sendError );