XhrHttpImpl considers any 2xx status to be successful
parent
6cc260b443
commit
d4328968e8
|
@ -151,13 +151,16 @@ module.exports = Class( 'XhrHttpImpl' )
|
||||||
* Determine whether the given HTTP status indicates a success or
|
* Determine whether the given HTTP status indicates a success or
|
||||||
* failure
|
* 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
|
* @param {number} status HTTP response status
|
||||||
*
|
*
|
||||||
* @return {bool} whether HTTP status represents a success
|
* @return {bool} whether HTTP status represents a success
|
||||||
*/
|
*/
|
||||||
'virtual protected isSuccessful': function( status )
|
'virtual protected isSuccessful': function( status )
|
||||||
{
|
{
|
||||||
return +status === 200;
|
return ( +status >= 200 ) && ( +status < 300 );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
it( 'allows overriding notion of success/failure', function( done )
|
||||||
{
|
{
|
||||||
var chk = 12345;
|
var chk = 12345;
|
||||||
|
|
Loading…
Reference in New Issue