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

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

[nongnu] elpa/request 2364e18 01/11: add headers slot into request-respo


From: ELPA Syncer
Subject: [nongnu] elpa/request 2364e18 01/11: add headers slot into request-response structure
Date: Sat, 13 Feb 2021 19:57:09 -0500 (EST)

branch: elpa/request
commit 2364e18b234d23c1092fa6e5dbf094a8371f05f2
Author: Naoya Yamashita <conao3@gmail.com>
Commit: Naoya Yamashita <conao3@gmail.com>

    add headers slot into request-response structure
---
 request.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/request.el b/request.el
index dfb8bce..0863b53 100644
--- a/request.el
+++ b/request.el
@@ -234,7 +234,7 @@ for older Emacs versions.")
 (cl-defstruct request-response
   "A structure holding all relevant information of a request."
   status-code history data error-thrown symbol-status url
-  done-p settings
+  done-p settings headers
   ;; internal variables
   -buffer -raw-header -timer -backend)
 
@@ -604,6 +604,14 @@ raw-header slot."
         (when (re-search-forward "^$" nil t)
           (setf (request-response--raw-header response)
                 (buffer-substring (point-min) (point)))
+          (setf (request-response-headers response)
+                (let (headers)
+                  (with-temp-buffer
+                    (insert (request-response--raw-header response))
+                    (goto-char (point-min))
+                    (while (re-search-forward "^\\([^:\n]+\\): \\(.*\\)$" nil 
'no-error)
+                      (push `(,(match-string 1) . ,(match-string 2)) headers))
+                    (nreverse headers))))
           (request-log 'trace "request--cut-header: cutting\n%s"
                        (buffer-substring (point-min) (min (1+ (point)) 
(point-max))))
           (delete-region (point-min) (min (1+ (point)) (point-max))))))))



reply via email to

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