sbis3-bl-request
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -6,4 +6,18 @@ 'use strict'; | ||
var https = require('https'); | ||
var HTTPAgent = http.Agent; | ||
var HTTPSAgent = https.Agent; | ||
var url = require('url'); | ||
var agentConfig = { | ||
maxSockets: 400, | ||
maxFreeSockets: 100, | ||
keepAlive: true, | ||
keepAliveMsecs: 60000 | ||
}; | ||
var agents = { | ||
http: new HTTPAgent(agentConfig), | ||
https: new HTTPSAgent(agentConfig) | ||
}; | ||
function doRequest(connection, reqParams) { | ||
@@ -13,12 +27,24 @@ var urlInfo = url.parse(connection.hostname); | ||
var protocol = isHTTPS ? https : http; | ||
var deferred = q.defer(); | ||
var sid, ua; | ||
connection.hostname = urlInfo.hostname; | ||
connection.port = isHTTPS ? 443 : 80; | ||
var deferred = q.defer(); | ||
connection.agent = agents[connection.port == 443 ? 'https' : 'http']; | ||
if (reqParams.sid) { | ||
var sid = reqParams.sid; | ||
sid = reqParams.sid; | ||
delete reqParams.sid; | ||
} | ||
if (reqParams.ua) { | ||
ua = reqParams.ua; | ||
delete reqParams.ua; | ||
} | ||
var params = _preparePackage(reqParams.method, reqParams.data); | ||
connection.headers = params.reqHeaders; | ||
sid ? (connection.headers['X-SBISSessionID'] = sid) : false; | ||
connection.headers['User-Agent'] = ua ? ua : 'SbisBLRequest'; | ||
@@ -88,3 +114,3 @@ var req = protocol.request(connection, function (res) { | ||
'Content-Length': Buffer.byteLength(stringifyBody), | ||
'User-Agent': 'SbisBLRequest' | ||
'Connection': 'keep-alive' | ||
}; | ||
@@ -91,0 +117,0 @@ return { |
{ | ||
"name": "sbis3-bl-request", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "q": "^1.1.2" |
5657
163