方法说明:

结束响应,告诉客户端所有消息已经发送。当所有要返回的内容发送完毕时,该函数必须被调用一次。

如果不调用该函数,客户端将永远处于等待状态。

语法:

1 response.end([data], [encoding])

接收参数:

data:end()执行完毕后要输出的字符,如果指定了 data 的值,那就意味着在执行完 response.end() 之后,会接着执行一条 response.write(data , encoding);

encoding:对应data的字符编码

例子:

1 var http=require('http');
2 var proxy=http.createServer(function(req,res){
3     res.writeHead('200',{'Content-Type':'text/plain'});
4     res.end('hello\n');
5 
6 });
7 proxy.listen('2000','127.0.0.1');

 

相关文章:

  • 2021-07-16
  • 2021-12-05
  • 2022-12-23
  • 2021-11-21
  • 2022-01-11
  • 2022-01-17
  • 2021-06-02
猜你喜欢
  • 2021-09-18
  • 2021-11-24
  • 2021-11-25
  • 2021-12-03
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案