Minor cleanup on connection request authentication code.

This commit is contained in:
Zaid Abdulla committed 2013-09-12 08:56:12 +03:00
1 parent 3c7f554264
commit a8ee773a39
2 files changed
+8 -6

No files matched your search

+5 -4
View File
@@ -9,11 +9,12 @@ auth = require './auth'
connectionRequest = (deviceId, callback) ->
conReq = (url, authString, callback) ->
if authString
url = URL.parse(url)
url.headers = {'Authorization' : authString}
options = URL.parse(url)
request = http.get(url, (res) ->
if authString
options.headers = {'Authorization' : authString}
request = http.get(options, (res) ->
if res.statusCode == 401
authHeader = auth.parseAuthHeader(res.headers['www-authenticate'])
callback(res.statusCode, authHeader)