问一个很弱的问题
 发布于 11 年前  作者 hoozi  4472 次预览  最后一次回复是 11 年前  来自 问答 

response.writeHead(200, {“Content-Type”: “text/plain”}); response.write(“hello world”); response.end();

response.writeHead(200, {“Content-Type”: “text/plain”}); response.write(); response.end(“hello world”);

输出写在end中和写在write中有什么区别

5 回复
jiyinyiyong

.end() 以后就不过 .write()

shanelau

.end() 以后会关闭输出流,无法再写入数据
.write() 可以执行多次 ,最后还是要执行一次 end()

alsotang

你把 end 当做是不接受参数的来理解,write 就是 写入,end 就是关闭那个 socket。

hoozi

@kissliux 原来如此,受教

hoozi

@alsotang 原来如此,受教