aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorIan Eure <ian@retrospec.tv>2020-05-03 11:01:01 -0700
committerIan Eure <ian@retrospec.tv>2020-05-03 11:01:01 -0700
commit605c2329076daf892d50c1407359655e5ca4c23d (patch)
treec79dcc939dc8c334bf1cfaf2e075863033ab36ed /lisp
parent5095797ef32b922d2a624fa6beb970b5e9cf5ca0 (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 7be4467..c255c81 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--get-json (url)
"Make GET request to URL. Return JSON response vector."