Skip to content

Commit

Permalink
Removes now unnecessary regexp and companion function. Fixes some spa…
Browse files Browse the repository at this point in the history
…cing issues. Shortens field names.
  • Loading branch information
jaubourg committed Apr 15, 2011
1 parent 4d3cb7d commit a519129
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions src/ajax.js
Expand Up @@ -15,10 +15,6 @@ var r20 = /%20/g,
rselectTextarea = /^(?:select|textarea)/i, rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/, rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
rucHeaders = /(^|\-)([a-z])/g,
rucHeadersFunc = function( _, $1, $2 ) {
return $1 + $2.toUpperCase();
},
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,


// Keep a copy of the old load method // Keep a copy of the old load method
Expand Down Expand Up @@ -416,7 +412,7 @@ jQuery.extend({
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
if ( !state ) { if ( !state ) {
requestHeaders[ name.toUpperCase().replace( rucHeaders, rucHeadersFunc ) ] = { name: name, value: value }; requestHeaders[ name.toLowerCase() ] = { n: name, v: value };
} }
return this; return this;
}, },
Expand Down Expand Up @@ -679,12 +675,12 @@ jQuery.extend({
} }


// Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader( jqXHR.setRequestHeader(
"Accept", "Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
s.accepts[ "*" ] s.accepts[ "*" ]
); );


// Check for headers option // Check for headers option
for ( i in s.headers ) { for ( i in s.headers ) {
Expand Down
2 changes: 1 addition & 1 deletion src/ajax/xhr.js
Expand Up @@ -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( headers[ i ].name, headers[ i ].value ); xhr.setRequestHeader( headers[ i ].n, headers[ i ].v );
} }
} catch( _ ) {} } catch( _ ) {}


Expand Down

0 comments on commit a519129

Please sign in to comment.