[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 54801f6 1/6: url-http-ntlm: Avoid calculating responses tw
From: |
Thomas Fitzsimmons |
Subject: |
[elpa] master 54801f6 1/6: url-http-ntlm: Avoid calculating responses twice |
Date: |
Thu, 6 Oct 2016 01:45:22 +0000 (UTC) |
branch: master
commit 54801f6afade1d36855482d0c28281c6697e1956
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>
url-http-ntlm: Avoid calculating responses twice
* packages/url-http-ntlm/url-http-ntlm.el
(url-http-ntlm--get-stage): Update docstring.
(url-ntlm-auth): Return immediately if prompt is not t. Update
docstring.
---
packages/url-http-ntlm/url-http-ntlm.el | 74 ++++++++++++++++---------------
1 file changed, 39 insertions(+), 35 deletions(-)
diff --git a/packages/url-http-ntlm/url-http-ntlm.el
b/packages/url-http-ntlm/url-http-ntlm.el
index 58622ad..3946151 100644
--- a/packages/url-http-ntlm/url-http-ntlm.el
+++ b/packages/url-http-ntlm/url-http-ntlm.el
@@ -148,16 +148,9 @@ request to the host in URL's server slot."
(defun url-http-ntlm--get-stage (args)
"Determine what stage of the NTLM handshake we are at.
-PROMPT and ARGS come from `url-ntlm-auth''s caller,
-`url-get-authentication'. Their meaning depends on the current
-implementation - this function is well and truly coupled.
-
-`url-get-authentication' calls `url-ntlm-auth' once when checking
-what authentication schemes are supported (PROMPT and ARGS are
-nil), and then twice for every stage of the handshake: the first
-time PROMPT is nil, the second, t; ARGS contains the server
-response's \"WWW-Authenticate\" header, munged by
-`url-parse-args'."
+ARGS comes from `url-ntlm-auth''s caller,
+`url-get-authentication'. Its meaning depends on the current
+implementation -- this function is well and truly coupled."
(cl-declare (special url-http-extra-headers))
(let* ((response-rxp "^NTLM TlRMTVNTUAADAAA")
(challenge-rxp "^TLRMTVNTUAACAAA")
@@ -275,36 +268,47 @@ two-step process, this function expects to be called
twice, first
to generate the NTLM type 1 message (request), then to respond to
the server's type 2 message (challenge) with a suitable response.
-PROMPT, OVERWRITE, and REALM are ignored.
+url-get-authentication' calls `url-ntlm-auth' once when checking
+what authentication schemes are supported (PROMPT and ARGS are
+nil), and then twice for every stage of the handshake: the first
+time PROMPT is nil, the second, t; ARGS contains the server
+response's \"WWW-Authenticate\" header, munged by
+`url-parse-args'.
+
+If PROMPT is not t then this function just returns nil. This is
+to avoid calculating responses twice.
+
+OVERWRITE and REALM are ignored.
ARGS is expected to contain the WWW-Authentication header from
the server's last response. These are used by
`url-http-get-stage' to determine what stage we are at."
- (url-http-ntlm--ensure-keepalive)
- (let* ((user-url (url-http-ntlm--ensure-user url))
- (stage (url-http-ntlm--get-stage args)))
- (url-debug 'url-http-ntlm "Stage: %s" stage)
- (cl-case stage
- ;; NTLM Type 1 message: the request
- (:request
- (url-http-ntlm--detect-loop user-url)
- (cl-destructuring-bind (&optional key hash)
- (url-http-ntlm--authorization user-url nil realm)
- (when (cl-third key)
- (url-http-ntlm--string
- (ntlm-build-auth-request (cl-second key) (cl-third key))))))
- ;; NTLM Type 3 message: the response
- (:response
- (url-http-ntlm--detect-loop user-url)
- (let ((challenge (url-http-ntlm--get-challenge)))
- (cl-destructuring-bind (key hash)
+ (when (eq prompt t)
+ (url-http-ntlm--ensure-keepalive)
+ (let* ((user-url (url-http-ntlm--ensure-user url))
+ (stage (url-http-ntlm--get-stage args)))
+ (url-debug 'url-http-ntlm "Stage: %s" stage)
+ (cl-case stage
+ ;; NTLM Type 1 message: the request
+ (:request
+ (url-http-ntlm--detect-loop user-url)
+ (cl-destructuring-bind (&optional key hash)
(url-http-ntlm--authorization user-url nil realm)
- (url-http-ntlm--string
- (ntlm-build-auth-response challenge
- (cl-second key)
- hash)))))
- (:error
- (url-http-ntlm--authorization user-url :clear)))))
+ (when (cl-third key)
+ (url-http-ntlm--string
+ (ntlm-build-auth-request (cl-second key) (cl-third key))))))
+ ;; NTLM Type 3 message: the response
+ (:response
+ (url-http-ntlm--detect-loop user-url)
+ (let ((challenge (url-http-ntlm--get-challenge)))
+ (cl-destructuring-bind (key hash)
+ (url-http-ntlm--authorization user-url nil realm)
+ (url-http-ntlm--string
+ (ntlm-build-auth-response challenge
+ (cl-second key)
+ hash)))))
+ (:error
+ (url-http-ntlm--authorization user-url :clear))))))
;;; Register `url-ntlm-auth' HTTP authentication method.
- [elpa] master updated (378f13a -> d3cf8b2), Thomas Fitzsimmons, 2016/10/05
- [elpa] master 5b6ce1f 4/6: packages/excorporate: Acknowledge Fabio Leimgruber, Thomas Fitzsimmons, 2016/10/05
- [elpa] master 31f43d7 2/6: url-http-ntlm: Bump ntlm required version to 2.1.0, Thomas Fitzsimmons, 2016/10/05
- [elpa] master d3cf8b2 6/6: excorporate.el: Bump version to 0.7.6, Thomas Fitzsimmons, 2016/10/05
- [elpa] master ae8ede8 5/6: packages/excorporate: Bump url-http-ntlm required version to 2.0.3, Thomas Fitzsimmons, 2016/10/05
- [elpa] master 54801f6 1/6: url-http-ntlm: Avoid calculating responses twice,
Thomas Fitzsimmons <=
- [elpa] master a35ed63 3/6: url-http-ntlm: Bump version to 2.0.3, Thomas Fitzsimmons, 2016/10/05