aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-09 20:22:12 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-09 20:22:12 +0100
commit5cb9b991c0b59c572640ded6d1ce53f4ed408797 (patch)
treeda111c2cbbaf0c72bb047f41fac8b38a239cd9ca /lisp
parente847059950308eea45bb70736a33a6d4c348bfff (diff)
opt no-headers arg, only fetch when nil
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el18
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 1c6e1ae..36d53c9 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -148,29 +148,31 @@ SILENT means don't message."
"GET"
(mastodon-http--url-retrieve-synchronously url silent)))
-(defun mastodon-http--get-response (url &optional silent)
+(defun mastodon-http--get-response (url &optional no-headers silent)
"Make synchronous GET request to URL. Return JSON and response headers.
SILENT means don't message.
HEADERS means also return http response headers."
(with-current-buffer (mastodon-http--get url silent)
- (mastodon-http--process-response)))
+ (mastodon-http--process-response no-headers)))
(defun mastodon-http--get-json (url &optional silent)
"Return only JSON data from URL request.
SILENT means don't message."
- (car (mastodon-http--get-response url silent)))
+ (car (mastodon-http--get-response url :no-headers silent)))
(defun mastodon-http--process-json ()
"Return only JSON data from async URL request.
-Callback for `mastodon-http--get-json-async'."
- (car (mastodon-http--process-response)))
+Callback to `mastodon-http--get-json-async', usually `mastodon-tl--init*', is run on the result."
+ (car (mastodon-http--process-response :no-headers)))
-(defun mastodon-http--process-response ()
+(defun mastodon-http--process-response (&optional no-headers)
"Process http response.
-Return a cons of JSON list and http response headers."
+Return a cons of JSON list and http response headers.
+Callback to `mastodon-http--get-response-async', usually `mastodon-tl--init*', is run on the result."
;; view raw response:
;; (switch-to-buffer (current-buffer))
- (let ((headers (mastodon-http--process-headers)))
+ (let ((headers (unless no-headers
+ (mastodon-http--process-headers))))
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(let ((json-array-type 'list)