我们总是这样写:
http.createServer(function(req, res) {
req.on('data', function(){})
.on('end', function(){});
});
但问题是:我在 Class: http.IncomingMessage
中找不到任何 Event: data
或 Event: end
的气息在 https://nodejs.org/dist/latest-v6.x/docs/api/http.html
请告诉我原因。
最佳答案
在 HTTP.IncomingMessage 的文档中,它说:
It implements the Readable Stream interface, as well as the following additional events, methods, and properties.
如果您检查 Stream.Readable文档,您可以找到 Event: 'data'
和 Event: 'end'
。
关于Node.js:在文档中的 http.IncomingMessage 中找不到 'data' 、 'end' 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39957491/