branch: elpa/mastodon
commit 97034ec73e23b37f20f1adb9b1b2777e4a27ccef
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    http: roll our own response code. 2/2 fix a tl test.
---
 lisp/mastodon-http.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index a91f272dd4..fc456925e5 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -68,13 +68,21 @@ SILENT means don't message."
       (url-retrieve-synchronously url)
     (url-retrieve-synchronously url (or silent nil) nil 
mastodon-http--timeout)))
 
+(defun mastodon-http--response-status (resp)
+  "Return the status code from RESP, a response buffer."
+  ;; `url-http-parse-response' breaks tests, as
+  ;; `url-http-end-of-headers' not set, so we roll our own:
+  (with-current-buffer resp
+    (goto-char (point-min))
+    (skip-chars-forward " \t\n")    ; Skip any blank crap
+    (skip-chars-forward "/HPT0-9.") ; Skip HTTP Version "HTTP/X.Y"
+    (read (current-buffer))))
+
 (defun mastodon-http--triage (response success)
   "Determine if RESPONSE was successful.
 Call SUCCESS on RESPONSE if successful. Message status and JSON error
 from RESPONSE if unsuccessful."
-  (let ((status (with-current-buffer response
-                  ;; FIXME: breaks tests, as url-http-end-of-headers not set
-                  (url-http-parse-response))))
+  (let ((status (mastodon-http--response-status response)))
     (if (and (>= 200 status)
              (<= status 299))
         ;; (string-prefix-p "2" (number-to-string status))

Reply via email to