[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/with-url 24f6e46 6/6: Refactor the user-agent func
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] scratch/with-url 24f6e46 6/6: Refactor the user-agent function for reuse |
Date: |
Mon, 23 Jan 2017 20:42:28 +0000 (UTC) |
branch: scratch/with-url
commit 24f6e464ba4c031673c0d52d7de22fd5ec2260dd
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Refactor the user-agent function for reuse
---
lisp/url/url-http.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 81bb9b4..0c55bc0 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -242,6 +242,12 @@ request.")
(defun url-http-user-agent-string ()
"Compute a User-Agent string.
The string is based on `url-privacy-level' and `url-user-agent'."
+ (let ((ua-string (url-http-user-agent)))
+ (if ua-string (format "User-Agent: %s\r\n" (string-trim ua-string)) "")))
+
+(defun url-http-user-agent ()
+ "Compute a User-Agent string.
+The string is based on `url-privacy-level' and `url-user-agent'."
(let* ((hide-ua
(or (eq url-privacy-level 'paranoid)
(and (listp url-privacy-level)
@@ -251,8 +257,9 @@ The string is based on `url-privacy-level' and
`url-user-agent'."
(cond
((functionp url-user-agent) (funcall url-user-agent))
((stringp url-user-agent) url-user-agent)
- ((eq url-user-agent 'default)
(url-http--user-agent-default-string))))))
- (if ua-string (format "User-Agent: %s\r\n" (string-trim ua-string)) "")))
+ ((eq url-user-agent 'default)
+ (url-http--user-agent-default-string))))))
+ ua-string))
(defun url-http-create-request (&optional ref-url)
"Create an HTTP request for `url-http-target-url', referred to by REF-URL."
- [Emacs-diffs] scratch/with-url updated (0013b14 -> 24f6e46), Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 2e0a3a6 5/6: Make form submission work with with-url, Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 6ed787f 4/6: with-url now uses 'get, not "GET", Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 386c924 1/6: Switch headers to symbols instead of strings, Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 5745c3f 2/6: Use symbols for the get/post method instead of strings, Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 20c089e 3/6: Default to no encoding in headers, Lars Ingebrigtsen, 2017/01/23
- [Emacs-diffs] scratch/with-url 24f6e46 6/6: Refactor the user-agent function for reuse,
Lars Ingebrigtsen <=