diff options
-rw-r--r-- | lisp/mastodon-http.el | 18 |
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) |