Skip to content

Commit

Permalink
Don't attempt reconnect unless status code is 200
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Apr 17, 2017
1 parent 33aec48 commit af84476
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ function EventSource(url, eventSourceInitDict) {

if (res.statusCode !== 200) {
_emit('error', new Event('error', {status: res.statusCode}));
if (res.statusCode == 204) return self.close();
return
return self.close();
}

readyState = EventSource.OPEN;
Expand Down
2 changes: 1 addition & 1 deletion test/eventsource_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ describe('Reconnection', function () {
});
});

it('is not attempted when server responds with HTTP 204', function (done) {
it('is not attempted when server responds with non-200', function (done) {
createServer(function (err, server) {
if(err) return done(err);

Expand Down

0 comments on commit af84476

Please sign in to comment.