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

    add json headers/handling to http--patch
---
 fedi-http.el | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/fedi-http.el b/fedi-http.el
index 780c6b20f29..92061e23ac1 100644
--- a/fedi-http.el
+++ b/fedi-http.el
@@ -282,16 +282,26 @@ If JSON, encode params as JSON."
     (with-temp-buffer
       (fedi-http--url-retrieve-synchronously url))))
 
-(defun fedi-http--patch-json (url &optional params)
+(defun fedi-http--patch-json (url &optional params json)
   "Make synchronous PATCH request to URL. Return JSON response.
 Optionally specify the PARAMS to send."
-  (with-current-buffer (fedi-http--patch url params)
+  (with-current-buffer (fedi-http--patch url params json)
     (fedi-http--process-json)))
 
-(defun fedi-http--patch (base-url &optional params)
+(defun fedi-http--patch (url &optional params json)
   "Make synchronous PATCH request to BASE-URL.
 Optionally specify the PARAMS to send."
-  (let ((url (fedi-http--concat-params-to-url base-url params)))
+  (let* ((url-request-data
+          (when params
+            (if json
+                (json-encode params)
+              (fedi-http--build-params-string params))))
+         ;; (url (fedi-http--concat-params-to-url base-url params)))))
+         (headers (when json
+                    '(("Content-Type" . "application/json")
+                      ("Accept" . "application/json"))))
+         (url-request-extra-headers
+          (append url-request-extra-headers headers)))
     (fedi-http--url-retrieve-synchronously url)))
 
  ;; Asynchronous functions

Reply via email to