Commit a9a79ccc authored by Sam Bisbee's avatar Sam Bisbee

Continuing to map request headers using their name in uppercase for the index,...

Continuing to map request headers using their name in uppercase for the index, but we now map to an object with an unmodified name and value: { name: "", value: "" }. This prevents overwriting of the user's supplied headers, which many applications parse with case sensitivity, because we no longer use the modified, uppercase index when building the request.
parent 35d94259
...@@ -416,7 +416,7 @@ jQuery.extend({ ...@@ -416,7 +416,7 @@ jQuery.extend({
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
if ( !state ) { if ( !state ) {
requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value; requestHeaders[ name.toUpperCase().replace( rucHeaders, rucHeadersFunc ) ] = { name: name, value: value};
} }
return this; return this;
}, },
...@@ -664,24 +664,27 @@ jQuery.extend({ ...@@ -664,24 +664,27 @@ jQuery.extend({
// Set the correct header, if data is being sent // Set the correct header, if data is being sent
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
requestHeaders[ "Content-Type" ] = s.contentType; jqXHR.setRequestHeader( "Content-Type", s.contentType );
} }
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) { if ( s.ifModified ) {
ifModifiedKey = ifModifiedKey || s.url; ifModifiedKey = ifModifiedKey || s.url;
if ( jQuery.lastModified[ ifModifiedKey ] ) { if ( jQuery.lastModified[ ifModifiedKey ] ) {
requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ]; jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
} }
if ( jQuery.etag[ ifModifiedKey ] ) { if ( jQuery.etag[ ifModifiedKey ] ) {
requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ]; jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
} }
} }
// Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? jqXHR.setRequestHeader(
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : "Accept",
s.accepts[ "*" ]; s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
s.accepts[ "*" ]
);
// Check for headers option // Check for headers option
for ( i in s.headers ) { for ( i in s.headers ) {
......
...@@ -104,7 +104,7 @@ if ( jQuery.support.ajax ) { ...@@ -104,7 +104,7 @@ if ( jQuery.support.ajax ) {
// Need an extra try/catch for cross domain requests in Firefox 3 // Need an extra try/catch for cross domain requests in Firefox 3
try { try {
for ( i in headers ) { for ( i in headers ) {
xhr.setRequestHeader( i, headers[ i ] ); xhr.setRequestHeader( headers[ i ].name, headers[ i ].value );
} }
} catch( _ ) {} } catch( _ ) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment