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)
J
.end() 以后就不过 .write() 了
S
.end() 以后会关闭输出流,无法再写入数据
.write() 可以执行多次 ,最后还是要执行一次 end()
A
你把 end 当做是不接受参数的来理解,write 就是 写入,end 就是关闭那个 socket。
H
引用 shanelau.end() 以后会关闭输出流,无法再写入数据 .write() 可以执行多次 ,最后还是要执行一次 end()
@kissliux 原来如此,受教
H
引用 alsotang你把 end 当做是不接受参数的来理解,write 就是 写入,end 就是关闭那个 socket。
@alsotang 原来如此,受教
参与回复
登录后即可参与回复。登录