- 基本服务器看起来不错,除了:
有一个
return失踪的语句。
res.write('404 Not Foundn');res.end();return; // <- Don't forget to return here !!和:
res.writeHead(200, mimeType);
应该:
res.writeHead(200, {'Content-Type':mimeType});- 是的
pipe()
,基本上是这样做的,它还会暂停/恢复源流(以防接收器变慢)。这是该pipe()
函数的源代码:https : //github.com/joyent/node/blob/master/lib/stream.js



