我有以下相当简单的代码(在coffeescript中):
http = require 'http'
options =
hostname: 'somewebsite.com'
port: 80,
path: '/'
server = http.createServer (request, response) ->
response.writeHead 200, 'text/html'
req = http.get options, (res) ->
res.on 'data', (data) ->
console.log 'GETTING IT'
response.write data
res.on 'end', () ->
console.log 'GOT IT'
response.end()
server.listen 80
我的印象是,一旦请求完成,就会调用 res.on 'end',但每当我执行代码时,都会多次调用回调。有什么帮助吗?