Skip to content
Permalink
Browse files

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

  • Loading branch information
jaubourg committed May 23, 2013
1 parent eabb56c commit a2cd89a795067d67d8212a4571991e5d2fb0ea8f
Showing with 24 additions and 1 deletion.
  1. +1 −1 src/ajax.js
  2. +23 −0 test/unit/ajax.js
@@ -614,7 +614,7 @@ jQuery.extend({
}

// if no content
if ( status === 204 ) {
if ( status === 204 || s.type === "HEAD" ) {
statusText = "nocontent";

// if not modified
@@ -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, {

0 comments on commit a2cd89a

Please sign in to comment.
You can’t perform that action at this time.