]> git.eshelyaron.com Git - emacs.git/commitdiff
(url-http-handle-authentication): If there are several authentication
authorMagnus Henoch <mange@freemail.hu>
Thu, 2 Nov 2006 23:06:20 +0000 (23:06 +0000)
committerMagnus Henoch <mange@freemail.hu>
Thu, 2 Nov 2006 23:06:20 +0000 (23:06 +0000)
headers, use the first with a supported method.

lisp/url/ChangeLog
lisp/url/url-http.el

index 1d4c4aa24fc24a8a4bb846e00c91e2dd9e1efc63..678e7e5a8db16e063d97f280dca9231d21f413cf 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-03  Shun-ichi GOTO  <gotoh@taiyo.co.jp> (tiny change)
+
+       * url-http.el (url-http-handle-authentication): If there are
+       several authentication headers, use the first with a supported
+       method.
+
 2006-11-01  Magnus Henoch  <mange@freemail.hu>
 
        * url-http.el (url-http-create-request): Use buffer-local
index 6b6ec7d6b223f56d608f7ec49e0883780f99edc2..c0bc2d9739e2e7f434e7afdcf1fbfed13b44e36b 100644 (file)
@@ -305,21 +305,29 @@ This allows us to use `mail-fetch-field', etc."
   (declare (special status success url-http-method url-http-data
                    url-callback-function url-callback-arguments))
   (url-http-debug "Handling %s authentication" (if proxy "proxy" "normal"))
-  (let ((auth (or (mail-fetch-field (if proxy "proxy-authenticate" "www-authenticate"))
-                 "basic"))
+  (let ((auths (or (nreverse
+                   (mail-fetch-field
+                    (if proxy "proxy-authenticate" "www-authenticate")
+                    nil nil t))
+                 '("basic")))
        (type nil)
        (url (url-recreate-url url-current-object))
        (url-basic-auth-storage 'url-http-real-basic-auth-storage)
-       )
-
+       auth)
     ;; Cheating, but who cares? :)
     (if proxy
        (setq url-basic-auth-storage 'url-http-proxy-basic-auth-storage))
 
-    (setq auth (url-eat-trailing-space (url-strip-leading-spaces auth)))
-    (if (string-match "[ \t]" auth)
-       (setq type (downcase (substring auth 0 (match-beginning 0))))
-      (setq type (downcase auth)))
+    ;; find first supported auth
+    (while auths
+      (setq auth (url-eat-trailing-space (url-strip-leading-spaces (car auths))))
+      (if (string-match "[ \t]" auth)
+         (setq type (downcase (substring auth 0 (match-beginning 0))))
+       (setq type (downcase auth)))
+      (if (url-auth-registered type)
+         (setq auths nil)              ; no more check
+       (setq auth nil
+             auths (cdr auths))))
 
     (if (not (url-auth-registered type))
        (progn