Skip to content

Commit

Permalink
fixed incorrect content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch committed Sep 19, 2012
1 parent e485067 commit ee63879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion HISTORY.md
@@ -1,5 +1,8 @@
# History

## 0.6.4

- Fixed incorrect Content-Length response header.

## 0.6.3

Expand All @@ -17,7 +20,7 @@

## 0.6.2

- Fixed rare but annoying bug where server would crash for no good reason ("Cannot set headers") on a request
- Fixed rare but annoying bug where server would crash for no good reason ("Cannot set headers") on a request

## 0.6.1

Expand Down
6 changes: 5 additions & 1 deletion lib/context.js
Expand Up @@ -93,7 +93,11 @@ Context.prototype.done = function(err, res) {

try {
if(status != 204 && status != 304) {
if(body && body.length) this.res.setHeader('Content-Length', body.length);
if(body) {
this.res.setHeader('Content-Length', Buffer.isBuffer(body)
? body.length
: Buffer.byteLength(body));
}
this.res.setHeader('Content-Type', type);
this.res.end(body);
} else {
Expand Down

0 comments on commit ee63879

Please sign in to comment.