1
0
Fork 0

XhrHttpImpl considers any 2xx status to be successful

master
Mike Gerwitz 2015-05-12 14:06:02 -04:00
parent 6cc260b443
commit d4328968e8
2 changed files with 20 additions and 1 deletions

View File

@ -151,13 +151,16 @@ module.exports = Class( 'XhrHttpImpl' )
* Determine whether the given HTTP status indicates a success or
* failure
*
* The default implementation is to consider any 2xx status code to be
* successful, as indicated by RFC 2616.
*
* @param {number} status HTTP response status
*
* @return {bool} whether HTTP status represents a success
*/
'virtual protected isSuccessful': function( status )
{
return +status === 200;
return ( +status >= 200 ) && ( +status < 300 );
}
} );

View File

@ -181,6 +181,22 @@ describe( 'XhrHttpImpl', function()
} );
it( 'considers any 2xx status to be successful', function( done )
{
var StubXhr = createStubXhr();
StubXhr.prototype.status = 250;
Sut( StubXhr )
.requestData( 'http://foo', 'GET', '', function( err, _ )
{
expect( err ).to.equal( null );
done();
} );
StubXhr.inst.send( '' );
} );
it( 'allows overriding notion of success/failure', function( done )
{
var chk = 12345;