emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon cada9d84d1 02/22: port fedi-http handling of POST


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon cada9d84d1 02/22: port fedi-http handling of POST JSON data or not
Date: Thu, 5 Oct 2023 07:00:53 -0400 (EDT)

branch: elpa/mastodon
commit cada9d84d13e0df5eeafa97f00e34c56a46473b8
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    port fedi-http handling of POST JSON data or not
---
 lisp/mastodon-http.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index ab621a2d47..cb4c32396c 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]