From: Julian Aubourg Date: Thu, 23 May 2013 00:11:37 +0000 (+0200) Subject: Handles HEAD requests as if they always were 204. Fixes #13922. X-Git-Tag: 1.10.0~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=53095883ef423260270de50b387eb5b17963d333;p=jquery.git Handles HEAD requests as if they always were 204. Fixes #13922. --- diff --git a/src/ajax.js b/src/ajax.js index 4478034d9..540a904b2 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -615,7 +615,7 @@ jQuery.extend({ } // if no content - if ( status === 204 ) { + if ( status === 204 || s.type === "HEAD" ) { statusText = "nocontent"; // if not modified diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 74307cb79..21ecdd2f7 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -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() ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {