aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/url
diff options
context:
space:
mode:
authorMark A. Hershberger2010-06-22 12:48:53 -0400
committerMark A. Hershberger2010-06-22 12:48:53 -0400
commit04c23739823fecd98cbc06ad627b36e5bd8e482e (patch)
tree743c052ea388d68d0ed259cf1e4fee7c94b6fbbe /lisp/url
parentbc869eca8c91810c66ead464b57630ccebabaf29 (diff)
downloademacs-04c23739823fecd98cbc06ad627b36e5bd8e482e.tar.gz
emacs-04c23739823fecd98cbc06ad627b36e5bd8e482e.zip
Add in some useful convenience functions for handling HTTP.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/ChangeLog6
-rw-r--r--lisp/url/url-parse.el20
2 files changed, 26 insertions, 0 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 374333150c8..4499ea5ff52 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,9 @@
12010-06-22 Mark A. Hershberger <mah@everybody.org>
2
3 * url-parse.el (url-user-for-url, url-password-for-url):
4 Convenience functions that get usernames and passwords for urls
5 from auth-source functions.
6
12010-06-12 Štěpán Němec <stepnem@gmail.com> (tiny change) 72010-06-12 Štěpán Němec <stepnem@gmail.com> (tiny change)
2 8
3 * url-vars.el (url-privacy-level): Fix doc typo. (Bug#6406) 9 * url-vars.el (url-privacy-level): Fix doc typo. (Bug#6406)
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index e68e0791558..20432dcf7e5 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -25,6 +25,7 @@
25;;; Code: 25;;; Code:
26 26
27(require 'url-vars) 27(require 'url-vars)
28(require 'auth-source)
28(eval-when-compile (require 'cl)) 29(eval-when-compile (require 'cl))
29 30
30(autoload 'url-scheme-get-property "url-methods") 31(autoload 'url-scheme-get-property "url-methods")
@@ -174,6 +175,25 @@ TYPE USER PASSWORD HOST PORTSPEC FILENAME TARGET ATTRIBUTES FULLNESS."
174 (url-parse-make-urlobj 175 (url-parse-make-urlobj
175 prot user pass host port file refs attr full))))))) 176 prot user pass host port file refs attr full)))))))
176 177
178(defmacro url-bit-for-url (method lookfor url)
179 `(let* ((urlobj (url-generic-parse-url url))
180 (bit (funcall ,method urlobj))
181 (methods (list 'url-recreate-url
182 'url-host)))
183 (while (and (not bit) (> (length methods) 0))
184 (setq bit
185 (auth-source-user-or-password
186 ,lookfor (funcall (pop methods) urlobj) (url-type urlobj))))
187 bit))
188
189(defun url-user-for-url (url)
190 "Attempt to use .authinfo to find a user for this URL."
191 (url-bit-for-url 'url-user "login" url))
192
193(defun url-password-for-url (url)
194 "Attempt to use .authinfo to find a password for this URL."
195 (url-bit-for-url 'url-password "password" url))
196
177(provide 'url-parse) 197(provide 'url-parse)
178 198
179;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403 199;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403