branch: elpa/fedi
commit a25c72c4d61ac8cb86305723c7bf36b3d3b2e19f
Author: Sergey Trofimov <[email protected]>
Commit: Sergey Trofimov <[email protected]>
http: add response status code to headers alist
---
fedi-http.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/fedi-http.el b/fedi-http.el
index 378193bea0..353169ff5b 100644
--- a/fedi-http.el
+++ b/fedi-http.el
@@ -39,6 +39,8 @@
(require 'json)
;; (require 'request) ; for attachments upload
(require 'url)
+(defvar url-http-response-status)
+(defvar url-http-end-of-headers)
(autoload 'shr-render-buffer "shr")
(autoload 'fedi-auth--access-token "fedi-auth")
@@ -329,12 +331,14 @@ Callback to `fedi-http--get-response-async'."
(goto-char (point-min))
(let* ((head-str (buffer-substring-no-properties
(point-min)
- (re-search-forward "^$" nil 'move)))
+ (- url-http-end-of-headers 1)))
(head-list (split-string head-str "\n")))
- (mapcar (lambda (x)
- (let ((list (split-string x ": ")))
- (cons (car list) (cadr list))))
- head-list)))
+ (cons
+ (cons 'status url-http-response-status)
+ (mapcar (lambda (x)
+ (let ((sep (string-search ": " x)))
+ (cons (substring x 0 sep) (substring x (+ 2 sep)))))
+ (cdr head-list)))))
;;; ASYNCHRONOUS FUNCTIONS