跳到主要内容
CNode

问一个很弱的问题

问答
Hhoozi发布于 12 年前最后回复 12 年前
547230

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)

A
alsotang#312 年前

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

S
shanelau#212 年前

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

J
jiyinyiyong#112 年前

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

参与回复

登录后即可参与回复。登录