English 中文(简体)
兔子洞下面的兔子洞 - "雷斯"从哪里来 起源于快报和(或)节点?
原标题:Down the rabbit hole - Where does "res" originate from in express and/or nodejs?

我试图理解更多的 Express 和 nodejs 内部 。 在 Express < code> response.js 文件中, 它经常为 < code> response.js 指定几种方法, 似乎是一个原型 。

具体而言, res 被宣布为 res = http.serverResponse.prototype

OK,那么,什么是 ? 是被宣布为 http http = expected(http)

因此,在 http.js 文件中,我们可以看到 exports=模块.exports = HTTPServer;

HTTPServer 似乎就是这个方法:

function HTTPServer(middleware){
  connect.HTTPServer.call(this, []);
  this.init(middleware);
};

这就是我被困的地方。根据我的逻辑, 似乎 < code> ServerResponse 被调用到 < code> HTTPServer 方法上, 这当然不合理。 因此, 我一定漏掉了一些东西 。

更新:

我刚刚意识到 Express创造了HTTP服务商的例子:

exports.createServer = function(options){
  if ( object  == typeof options) {
    return new HTTPSServer(options, Array.prototype.slice.call(arguments, 1));
  } else {
    return new HTTPServer(Array.prototype.slice.call(arguments));
  }
};

因此,我猜想,这个例子实际上被调用到ServerResponse ?但我仍然无法找到ServerResponse ...

最佳回答

https://github.com/visionmedia/表达/表达/tree/master/lib" rel=“nofollow”>表达源文件 。

根据>node.js上的文件,http http=需要(http) 将装载有 的http模块,http://nodejs.org/api/http.html#http_clasle_http_server response" rel="nofolfol"\code>>_serverRescolve united

因此,明确的代码会用附加方法增强服务器响应对象。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签