]> source.dussan.org Git - jquery.git/commitdiff
Handles HEAD requests as if they always were 204. Fixes #13922.
authorJulian Aubourg <j@ubourg.net>
Thu, 23 May 2013 00:11:37 +0000 (02:11 +0200)
committerJulian Aubourg <j@ubourg.net>
Thu, 23 May 2013 00:39:20 +0000 (02:39 +0200)
src/ajax.js
test/unit/ajax.js

index 4478034d9a93fa4585860c5b7c69b1c0a527c45b..540a904b2bdc475fdee2a7e83c95ce82b9344645 100644 (file)
@@ -615,7 +615,7 @@ jQuery.extend({
                                }
 
                                // if no content
-                               if ( status === 204 ) {
+                               if ( status === 204 || s.type === "HEAD" ) {
                                        statusText = "nocontent";
 
                                // if not modified
index 74307cb79b9ebbfae7acfdf55399b67464c34919..21ecdd2f7370bcdcb9ea29a0e4af25a777a7967c 100644 (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()
 
        ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {