“Nodejs/http/createServer”的版本间的差异

来自小青青的笔记
< Nodejs‎ | http
跳到导航 跳到搜索
options
requestListener
第17行: 第17行:
  
 
===requestListener <Function>===
 
===requestListener <Function>===
 +
当触发[[Nodejs/http/Server/request|request事件]]时执行的函数。
 +
 
==返回值==
 
==返回值==
 
返回: <[[Nodejs/http/Server|http.Server]]>
 
返回: <[[Nodejs/http/Server|http.Server]]>

2019年5月27日 (一) 15:11的版本

http.createServer([options][, requestlistener])

版本历史

版本 变更
v9.6.0 现在支持options参数
v0.1.13 新增于: v0.1.13

参数

options <Object>

我也没用过这个参数。

  • IncomingMessage <http.IncomingMessage> 指定要使用的 IncomingMessage 类。用于扩展原始的 IncomingMessage。默认值: IncomingMessage。
  • ServerResponse <http.ServerResponse> 指定要使用的 ServerResponse 类。用于扩展原始 ServerResponse。默认值: ServerResponse。

requestListener <Function>

当触发request事件时执行的函数。

返回值

返回: <http.Server> 返回新建的 http.Server 实例。

备注

requestListener 是一个自动添加到 'request' 事件的函数。