diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-05 10:57:31 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-05 10:57:31 +0200 |
commit | b8517fa6d65c9de75fef4a61742251811e9f2b96 (patch) | |
tree | b49241432f0922f989302af0731316d2dbd2e6f0 /lisp/mastodon-http.el | |
parent | 5e12dc998527673cdb3350c6370570a256bfab5f (diff) | |
parent | 1964ee8ad6a0cd91a149a11925e1bcd94c83c072 (diff) |
Merge branch 'develop'
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index ab621a2..cb4c323 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -127,17 +127,20 @@ Used for API form data parameters that take an array." (cl-loop for x in array collect (cons param-str x))) -(defun mastodon-http--post (url &optional params headers unauthenticated-p) +(defun mastodon-http--post (url &optional params headers unauthenticated-p json) "POST synchronously to URL, optionally with PARAMS and HEADERS. Authorization header is included by default unless UNAUTHENTICATED-P is non-nil." (mastodon-http--authorized-request "POST" - (let ((url-request-data (when params - (mastodon-http--build-params-string params))) - (url-request-extra-headers - (append url-request-extra-headers ; auth set in macro - (unless (assoc "Content-Type" headers) ; pleroma compat: - '(("Content-Type" . "application/x-www-form-urlencoded"))) - headers))) + (let* ((url-request-data + (when params + (if json + (json-encode params) + (fedi-http--build-params-string params)))) + (url-request-extra-headers + (append url-request-extra-headers ; auth set in macro + (unless (assoc "Content-Type" headers) ; pleroma compat: + '(("Content-Type" . "application/x-www-form-urlencoded"))) + headers))) (with-temp-buffer (mastodon-http--url-retrieve-synchronously url))) unauthenticated-p)) |