Commit 2e00deca authored by antoor's avatar antoor

Set the request-timeout && user-agent

设置请求超时以及新版本UA
parent 6cdbb500
/** /**
* HTTP后端数据发送处理函数 * HTTP后端数据发送处理函数
* 更新: 2016/04/25 * 更新: 2016/05/07
*/ */
'use strict'; 'use strict';
const fs = require('fs'), const fs = require('fs'),
iconv = require('iconv-lite'), iconv = require('iconv-lite'),
// logger = require('log4js').getLogger('Request'),
// Logger = require('./logger'),
through = require('through'), through = require('through'),
superagent = require('superagent'), superagent = require('superagent'),
superagentProxy = require('superagent-proxy'); superagentProxy = require('superagent-proxy');
let logger; let logger;
// 请求UA // 请求UA
const USER_AGENT = 'antSword/v1.3'; const USER_AGENT = 'antSword/v2.0';
// 请求超时 // 请求超时
const REQ_TIMEOUT = 5000; const REQ_TIMEOUT = 10000;
// 代理配置 // 代理配置
const APROXY_CONF = { const APROXY_CONF = {
...@@ -232,7 +230,7 @@ class Request { ...@@ -232,7 +230,7 @@ class Request {
res.data += finalData; res.data += finalData;
}); });
res.on('end', () => { res.on('end', () => {
logger.info('end::size=' + res.data.length, res.data.length < 10 ? res.data : ''); logger.info(`end.size=${res.data.length}`, res.data);
callback(null, new Buffer(res.data, 'binary')); callback(null, new Buffer(res.data, 'binary'));
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment