Skip to content

Commit

Permalink
Write head before sending data
Browse files Browse the repository at this point in the history
  • Loading branch information
jxson committed Feb 21, 2015
1 parent 7abac5a commit f6bb5db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/res-beardo.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ Engine.prototype.serve = function(req, res) {

var etag = hash(output)

res.setHeader('etag', etag)

debug('req.etag %s', req.headers['if-none-match'])
debug('etag: %s', etag)

if (req.headers['if-none-match'] === etag) {
res.statusCode = 304
res.writeHead(304)
} else {
res.statusCode = status || 200
res.setHeader('etag', hash(output))
res.writeHead(status || 200)
res.write(output)
}

Expand Down

0 comments on commit f6bb5db

Please sign in to comment.