aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-05-08 14:34:19 +0200
committermousebot <mousebot@riseup.net>2021-05-09 11:22:42 +0200
commit416709661936d16a854b15c0622ae5d29e2f50c8 (patch)
tree13b0e086d1c8b53eb38e517d0c2c443c902cf7b9 /lisp
parent6d944039bef1288745ae5535f6a407bb7cef1a51 (diff)
Set a HTTP timeout.
This prevents mastodon.el from locking Emacs and spinning forever.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index da4b91a..a6e9c92 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -35,6 +35,9 @@
(defvar mastodon-http--api-version "v1")
+(defconst mastodon-http--timeout 5
+ "HTTP request timeout, in seconds.")
+
(defun mastodon-http--api (endpoint)
"Return Mastondon API URL for ENDPOINT."
(concat mastodon-instance-url "/api/"
@@ -86,7 +89,7 @@ Authorization header is included by default unless UNAUTHENTICED-P is non-nil."
`(("Authorization" . ,(concat "Bearer " (mastodon-auth--access-token)))))
headers)))
(with-temp-buffer
- (url-retrieve-synchronously url))))
+ (url-retrieve-synchronously url nil nil mastodon-http--timeout))))
(defun mastodon-http--get (url)
"Make GET request to URL.
@@ -96,7 +99,7 @@ Pass response buffer to CALLBACK function."
(url-request-extra-headers
`(("Authorization" . ,(concat "Bearer "
(mastodon-auth--access-token))))))
- (url-retrieve-synchronously url)))
+ (url-retrieve-synchronously url nil nil mastodon-http--timeout)))
(defun mastodon-http--delete (url)
"Make DELETE request to URL.