From ab26ff2058607e32f3c8f8b0e1ee26b5f5f6cef4 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 2 Mar 2017 13:01:17 -0800 Subject: [PATCH] Fix a few digest authentication issues Resolves: #181 --- lib/api-functions.coffee | 2 +- lib/auth.coffee | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api-functions.coffee b/lib/api-functions.coffee index 6627469..915129e 100644 --- a/lib/api-functions.coffee +++ b/lib/api-functions.coffee @@ -82,7 +82,7 @@ udpConReq = (address, un, key, callback) -> httpConReq = (url, username, password, timeout, callback) -> options = URL.parse(url) # Ensure socket is reused in case of digest authentication - agent = new http.Agent({maxSockets : 1}) + options.agent = new http.Agent({maxSockets : 1}) statusToError = (statusCode) -> switch statusCode diff --git a/lib/auth.coffee b/lib/auth.coffee index 502db68..1089cb8 100644 --- a/lib/auth.coffee +++ b/lib/auth.coffee @@ -72,9 +72,7 @@ exports.digest = (username, password, uri, httpMethod, body, authHeader) -> authString += ",nonce=\"#{authHeader.nonce}\"" authString += ",uri=\"#{uri}\"" authString += ",algorithm=#{authHeader.algorithm}" if authHeader.algorithm? - authString += ",qop=#{qop}" - authString += ",nc=#{nc}" - authString += ",cnonce=\"#{cnonce}\"" + authString += ",qop=#{qop},nc=#{nc},cnonce=\"#{cnonce}\"" if qop? authString += ",response=\"#{response}\"" - authString += ",opaque=\"#{authHeader.opaque}\"" + authString += ",opaque=\"#{authHeader.opaque}\"" if authHeader.opaque? return authString