Skip to content

Commit

Permalink
encoding changes
Browse files Browse the repository at this point in the history
  • Loading branch information
toolness committed Aug 23, 2010
1 parent 5d5c59e commit f7ed60c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions nodepad/server.js
Expand Up @@ -43,13 +43,16 @@ exports.makeRequestHandler = function makeRequestHandler(git) {
else
respondWith500(err);
} else {
writeHead(200, {'Content-Type': 'text/plain'});
response.end(data);
var byteLength = Buffer.byteLength(data, 'utf8');
writeHead(200, {'Content-Type': 'text/plain',
'Content-Length': byteLength});
response.end(data, 'utf8');
}
});
else if (request.method == 'PUT') {
var chunks = [];
var length = 0;
request.setEncoding('utf8');
request.on(
'data',
function(chunk) {
Expand Down
4 changes: 2 additions & 2 deletions test/test-server.js
Expand Up @@ -53,7 +53,7 @@ var tests = [
function putIntoBin() {
var localhost = http.createClient(PORT);
var req = localhost.request('PUT', '/foo');
req.write('blop');
req.write('blop\u2026', 'utf8');
req.end();
req.on('response',
function(response) {
Expand All @@ -71,7 +71,7 @@ var tests = [
response.setEncoding('utf8');
response.on('data',
function(chunk) {
assert.equal(chunk, 'blop');
assert.equal(chunk, 'blop\u2026');
nextTest();
});
});
Expand Down

0 comments on commit f7ed60c

Please sign in to comment.