]> 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:11:37 +0000 (02:11 +0200)
src/ajax.js
test/unit/ajax.js

index d0a8a4f120dbdf17a9ef5f3ab1290141c49a3caa..8facc17fe51b02d51b266a5c25d0d8e283a7381f 100644 (file)
@@ -614,7 +614,7 @@ jQuery.extend({
                                }
 
                                // if no content
-                               if ( status === 204 ) {
+                               if ( status === 204 || s.type === "HEAD" ) {
                                        statusText = "nocontent";
 
                                // if not modified
index 2dd74c384f9a9355e5bbaea2debc6ab1fccae0ef..761885ccb8b98949126466e04bd3a0aa085db5e9 100644 (file)
@@ -1499,6 +1499,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, {