node.js中的http.response.writeHead方法使用说明
2014-12-14 00:00
966 查看
方法说明:
向请求的客户端发送响应头。
该函数在一个请求内最多只能调用一次,如果不调用,则会自动生成一个响应头。
语法:
接收参数:
statusCode HTTP状态码,如200(请求成功),404(未找到)等。
reasonPhrase
headers 类似关联数组的对象,表示响应头的每个属性
例子:
向请求的客户端发送响应头。
该函数在一个请求内最多只能调用一次,如果不调用,则会自动生成一个响应头。
语法:
response.writeHead(statusCode, [reasonPhrase], [headers])
接收参数:
statusCode HTTP状态码,如200(请求成功),404(未找到)等。
reasonPhrase
headers 类似关联数组的对象,表示响应头的每个属性
例子:
var body = 'hello world'; response.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' });
相关文章推荐
- node.js中的http.response.writeHead方法使用说明
- node.js中的http.response.setHeader方法使用说明
- node.js中的http.response.getHeader方法使用说明
- node.js中的http.response.end方法使用说明
- node.js中的http.response.getHeader方法使用说明
- node.js中的http.response.setHeader方法使用说明
- node.js中的http.response.write方法使用说明
- node.js中的http.response.removeHeader方法使用说明
- node.js中的http.response.end方法使用说明
- node.js中的http.response.addTrailers方法使用说明
- node.js中的http.response.addTrailers方法使用说明
- node.js中的http.response.removeHeader方法使用说明
- node.js中的http.response.write方法使用说明
- node.js中的http.createServer方法使用说明
- node.js中的http.request.end方法使用说明
- node.js中的http.response.writeHead方法
- node.js中的http.request方法使用说明
- node.js中的http.createClient方法使用说明
- node.js中的http.request方法使用说明_node.js
- node.js中的http.request.end方法使用说明