Handles HEAD requests as if they always were 204. Fixes #13922.

This commit is contained in:
Julian Aubourg 2013-05-23 02:11:37 +02:00
parent ef31479446
commit 53095883ef
2 changed files with 24 additions and 1 deletions

View File

@ -615,7 +615,7 @@ jQuery.extend({
} }
// if no content // if no content
if ( status === 204 ) { if ( status === 204 || s.type === "HEAD" ) {
statusText = "nocontent"; statusText = "nocontent";
// if not modified // if not modified

View File

@ -1542,6 +1542,29 @@ module( "ajax", {
} }
}); });
ajaxTest( "#13922 - jQuery.ajax() - converter is bypassed for HEAD requests", 3, {
url: "data/json.php",
method: "HEAD",
data: {
header: "yes"
},
converters: {
"text json": function() {
throw "converter was called";
}
},
success: function( data, status ) {
ok( true, "success" );
strictEqual( status, "nocontent", "data is undefined" );
strictEqual( data, undefined, "data is undefined" );
},
error: function( _, status, error ) {
ok( false, "error" );
strictEqual( status, "parsererror", "Parser Error" );
strictEqual( error, "converter was called", "Converter was called" );
}
} );
//----------- jQuery.ajaxPrefilter() //----------- jQuery.ajaxPrefilter()
ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, { ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {