node.js中的http.response.write方法使用说明

时间:2014-12-14    点击:96   

方法说明:

向请求的客户端发送响应内容。

在 response.end() 之前,response.write() 可以被执行多次。

语法:

复制代码 代码如下:

response.write(chunk, [encoding])

参数:

chunk                      是一个buffer 或 字符串,表示发送的内容

encoding                如果chunk是字符串,就需要指定encoding来说明它的编码方式,默认utf-8

例子:

复制代码 代码如下:

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.writeFile方法使用说明
node.js中的fs.writeFile方法使用说明
node.js中的http.response.addTrailers方法使用说明
node.js中的http.response.writeHead方法使用说明
node.js中的http.response.getHeader方法使用说明
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved