Meet Node.js followup

12 views
Skip to first unread message

khinester

unread,
Oct 7, 2010, 8:36:41 AM10/7/10
to PeepCode

here is a diff for my previous post, which i guess is still in
approval:

$ git diff server.js
diff --git a/server.js b/server.js
index 5c004e0..e367295 100644
--- a/server.js
+++ b/server.js
@@ -1,13 +1,13 @@
+require.paths.unshift(__dirname + "/vendor");
+
var http = require('http'),
- sys = require('sys');
+ sys = require('sys'),
+ nodeStatic = require('node-static/lib/node-static');

+var file = new(nodeStatic.Server)('./public', {cache: false});
var server = http.createServer(function(request, response) {
request.addListener('end', function() {
- response.writeHead(200, {
- 'Content-Type': 'text/plain'
- });
- response.write(sys.inspect(request));
- response.end();
- };)
+ file.serve(request, response);
+ })
})
-server.listen(8000);
\ No newline at end of file

also you will need to patch the node-static code

$ git diff lib/node-static.js
diff --git a/lib/node-static.js b/lib/node-static.js
index 1367c77..4639591 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -236,7 +236,7 @@ this.Server.prototype.stream = function (pathname,
files, buffer, res, callback)
mode: 0666,
bufferSize: 4096
}).addListener('data', function (chunk) {
- chunk.copy (buffer, offset, 0);
+ buffer.write(chunk, offset, 'binary');
res.write (chunk, 'binary');
offset += chunk.length;
}).addListener('close', function () {


topfunky

unread,
Oct 8, 2010, 3:14:58 PM10/8/10
to PeepCode
Thanks for the fix! I'll update the screencast and upload a fixed copy
early next week.

Geoffrey Grosenbach
http://peepcode.com

khinester

unread,
Oct 9, 2010, 5:35:31 AM10/9/10
to PeepCode
i made a push of the code here

http://github.com/nkhine/livestats
Reply all
Reply to author
Forward
0 new messages