[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/plz db15885357 1/5: Add: (plz-http-end-of-headers-regex
From: |
ELPA Syncer |
Subject: |
[elpa] externals/plz db15885357 1/5: Add: (plz-http-end-of-headers-regexp) |
Date: |
Sat, 31 Dec 2022 16:58:01 -0500 (EST) |
branch: externals/plz
commit db1588535775d79664f3c25cd2a4a9373e76d414
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: (plz-http-end-of-headers-regexp)
---
plz.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/plz.el b/plz.el
index 15cb5db0ee..6d354c70f9 100644
--- a/plz.el
+++ b/plz.el
@@ -118,6 +118,12 @@
"\r\n")
"Regular expression matching HTTP response status line.")
+(defconst plz-http-end-of-headers-regexp
+ (rx (or "\r\n\r\n" "\n\n"))
+ "Regular expression matching the end of HTTP headers.
+This must work with both HTTP/1 (using CRLF) and HTTP/2 (using
+only LF).")
+
(defconst plz-curl-errors
;; Copied from elfeed-curl.el.
'((1 . "Unsupported protocol.")
@@ -736,7 +742,7 @@ Assumes point is at start of HTTP response."
(save-excursion
(forward-line 1)
(let ((limit (save-excursion
- (re-search-forward "^\r\n" nil)
+ (re-search-forward plz-http-end-of-headers-regexp nil)
(point))))
(cl-loop while (re-search-forward (rx bol (group (1+ (not (in ":"))))
":" (1+ blank)
(group (1+ (not (in "\r\n")))))
@@ -751,7 +757,7 @@ Assumes point is at start of HTTP response."
(defun plz--narrow-to-body ()
"Narrow to body of HTTP response in current buffer.
Assumes point is at start of HTTP response."
- (unless (re-search-forward "^\r\n" nil t)
+ (unless (re-search-forward plz-http-end-of-headers-regexp nil t)
(signal 'plz-http-error '("plz--narrow-to-body: Unable to find end of
headers")))
(narrow-to-region (point) (point-max)))