文章
Nodejs HTTP请求的超时处理方法
2011/8/9 13:31:41
示例代码:Timeout Demo
var http = require('http');
var timer = null;
var options = {
host: 'www.google.com',
port: 80,
path: '/'
};
var req = http.get(options, function(res) {
clearTimeout(timer);
console.log("Got response: " + res.statusCode);
var chunks = [], length = 0;
res.on('data', function(chunk) {
length += chunk.length;
chunks.push(chunk);
});
res.on('end', function(){
var data = new Buffer(length);
// 延后copy
for(var i=0, pos=0, size=chunks.length; i
if ($ != jQuery) {
$ = jQuery.noConflict();
}
var isLogined = true;
var cb_blogId = 22105;
var cb_entryId = 2132825;
var cb_blogApp = "fengmk2";
var cb_blogUserGuid = "9862360b-63cf-dd11-9e4d-001cf0cd104b";
var cb_entryCreatedDate = '2011/8/9 21:30:00';
http://pdflist.mmic.net.cn