Fixed bug in connection request digest authentication caused authentication response being sent over a new connection
This commit is contained in:
1 parent
13960f9f20
commit
89f153de4d
1 file changed
+6
@@ -8,8 +8,12 @@ auth = require './auth'
|
||||
|
||||
|
||||
connectionRequest = (deviceId, callback) ->
|
||||
# ensure socket is reused in case of digest authentication
|
||||
agent = new http.Agent({maxSockets : 1})
|
||||
|
||||
conReq = (url, authString, callback) ->
|
||||
options = URL.parse(url)
|
||||
options.agent = agent
|
||||
|
||||
if authString
|
||||
options.headers = {'Authorization' : authString}
|
||||
@@ -18,6 +22,8 @@ connectionRequest = (deviceId, callback) ->
|
||||
if res.statusCode == 401
|
||||
authHeader = auth.parseAuthHeader(res.headers['www-authenticate'])
|
||||
callback(res.statusCode, authHeader)
|
||||
# don't need body, go ahead and emit events to free up the socket for possible reuse
|
||||
res.resume()
|
||||
)
|
||||
|
||||
request.on('error', (err) ->
|
||||
|
||||
Reference in new issue
Block a user