diff --git a/lib/index.js b/lib/index.js index 5287e4ead0..183e3e1b05 100644 --- a/lib/index.js +++ b/lib/index.js @@ -358,10 +358,11 @@ Server.prototype.serve = function(req, res){ // Per the standard, ETags must be quoted: // https://tools.ietf.org/html/rfc7232#section-2.3 var expectedEtag = '"' + clientVersion + '"'; + var weakEtag = 'W/' + expectedEtag; var etag = req.headers['if-none-match']; if (etag) { - if (expectedEtag == etag) { + if (expectedEtag == etag || weakEtag == etag) { debug('serve client 304'); res.writeHead(304); res.end(); diff --git a/test/socket.io.js b/test/socket.io.js index aec781455e..88e1b5ed62 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -182,6 +182,19 @@ describe('socket.io', function(){ }); }); + it('should handle 304 from weak etag', function(done){ + var srv = http(); + io(srv); + request(srv) + .get('/socket.io/socket.io.js') + .set('If-None-Match', 'W/"' + clientVersion + '"') + .end(function(err, res){ + if (err) return done(err); + expect(res.statusCode).to.be(304); + done(); + }); + }); + it('should not serve static files', function(done){ var srv = http(); io(srv, { serveClient: false });