Skip to content

Commit ddab0fe

Browse files
iceteedesandro
authored andcommitted
Supported 204 No content (#759)
Server can send 204 HTTP code. This indicates there is no more content. https://httpstatuses.com/204
1 parent a24528d commit ddab0fe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

js/page-load.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ proto.loadNextPage = function() {
6565
this.onPageError( error, path );
6666
}.bind( this );
6767

68-
request( path, this.options.responseType, onLoad, onError );
68+
var onLast = function( response ) {
69+
this.lastPageReached( response, path );
70+
}.bind( this );
71+
72+
request( path, this.options.responseType, onLoad, onError, onLast );
6973
this.dispatchEvent( 'request', null, [ path ] );
7074
};
7175

@@ -263,7 +267,7 @@ proto.stopPrefill = function() {
263267

264268
// -------------------------- request -------------------------- //
265269

266-
function request( url, responseType, onLoad, onError ) {
270+
function request( url, responseType, onLoad, onError, onLast ) {
267271
var req = new XMLHttpRequest();
268272
req.open( 'GET', url, true );
269273
// set responseType document to return DOM
@@ -275,6 +279,8 @@ function request( url, responseType, onLoad, onError ) {
275279
req.onload = function() {
276280
if ( req.status == 200 ) {
277281
onLoad( req.response );
282+
} else if ( req.status == 204 ) {
283+
onLast( req.response );
278284
} else {
279285
// not 200 OK, error
280286
var error = new Error( req.statusText );

0 commit comments

Comments
 (0)