aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2011-02-09 17:47:33 +0100
committerjaubourg <j@ubourg.net>2011-02-09 17:47:33 +0100
commitf6e173437e9f94cd4e713e556c6fc8ca68be8384 (patch)
tree8abefe24d3d21fd6e15d90a89456cadf2967ff3c /src
parent806d9ce8111128c4f30c6559c325f8a4ad1018a3 (diff)
downloadjquery-f6e173437e9f94cd4e713e556c6fc8ca68be8384.tar.gz
jquery-f6e173437e9f94cd4e713e556c6fc8ca68be8384.zip
Fixes #8219. Introduces the mimeType option to override content-type header in conversion (and in native xhr when possible). Adds companion overrideMimeType method on jqXHR object (it simply sets the option). Unit test added.
Diffstat (limited to 'src')
-rw-r--r--src/ajax.js10
-rw-r--r--src/ajax/xhr.js5
2 files changed, 14 insertions, 1 deletions
diff --git a/src/ajax.js b/src/ajax.js
index 15ad6a85c..5a6ac26ad 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -426,6 +426,14 @@ jQuery.extend({
return match || null;
},
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( state === 0 ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
// Cancel the request
abort: function( statusText ) {
statusText = statusText || "abort";
@@ -827,7 +835,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
while( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
- ct = jqXHR.getResponseHeader( "content-type" );
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
}
}
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index 1f136c343..fcea52c16 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -87,6 +87,11 @@ if ( jQuery.support.ajax ) {
}
}
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
// Requested-With header
// Not set for crossDomain requests with no content
// (see why at http://trac.dojotoolkit.org/ticket/9486)