node.js中的http.response.end方法使用说明
作者:bea
方法说明: 结束响应,告诉客户端所有消息已经发送。当所有要返回的内容发送完毕时,该函数必须被调用一次。 如何不调用该函数,客户端将永远处于等待状态。 语法: 代码如下: response.end([data], [encoding]) 接收参数: data end()执行完毕后要输出的字符,如果指定了 data 的值,那就意味着在执行完 response.end() 之后,会接着执行一条 response.write(data , encoding); encodi
方法说明:
结束响应,告诉客户端所有消息已经发送。当所有要返回的内容发送完毕时,该函数必须被调用一次。
如何不调用该函数,客户端将永远处于等待状态。
语法:
代码如下:
response.end([data], [encoding])
接收参数:
data end()执行完毕后要输出的字符,如果指定了 data 的值,那就意味着在执行完 response.end() 之后,会接着执行一条 response.write(data , encoding);
encoding 对应data的字符编码
例子:
代码如下:
var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);
有用 | 无用
结束响应,告诉客户端所有消息已经发送。当所有要返回的内容发送完毕时,该函数必须被调用一次。
如何不调用该函数,客户端将永远处于等待状态。
语法:
代码如下:
response.end([data], [encoding])
接收参数:
data end()执行完毕后要输出的字符,如果指定了 data 的值,那就意味着在执行完 response.end() 之后,会接着执行一条 response.write(data , encoding);
encoding 对应data的字符编码
例子:
代码如下:
var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- node.js中的fs.truncateSync方法使用说明
- node.js中的fs.truncate方法使用说明
- node.js中的fs.unlinkSync方法使用说明
- node.js中的fs.unlink方法使用说明
- 30个经典的jQuery代码开发技巧
- node.js中的fs.fsync方法使用说明
- innerHTML在IE中报错解决方案
- node.js中的fs.ftruncate方法使用说明
- node.js中的fs.fsyncSync方法使用说明
- node.js中的fs.writeSync方法使用说明
- node.js中的fs.write方法使用说明
- node.js中的http.createClient方法使用说明
- node.js中的http.get方法使用说明
- node.js中的http.createServer方法使用说明
- node.js中的fs.writeFileSync方法使用说明
- node.js中的http.response.addTrailers方法使用说明
- node.js中的http.response.writeHead方法使用说明
- node.js中的http.response.getHeader方法使用说明
- node.js中的http.response.write方法使用说明