[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/plz 1bb701f1c1 36/81: Change/Fix: Downcase and intern h
From: |
ELPA Syncer |
Subject: |
[elpa] externals/plz 1bb701f1c1 36/81: Change/Fix: Downcase and intern header keys |
Date: |
Wed, 11 May 2022 17:58:00 -0400 (EDT) |
branch: externals/plz
commit 1bb701f1c104314ec12e05f1c3ca0b9310b75c35
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Change/Fix: Downcase and intern header keys
Some HTTP servers send all-lowercase header keys, which means an alist
lookup with `equal' or `string=' fails when the case differs. We
don't want users to have to worry about this, so for consistency, we
downcase the header name. And while we're at it, we might as well
intern it so we can use `alist-get' without having to add "nil nil
'equal" every time.
---
plz.el | 7 ++++++-
tests/test-plz.el | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/plz.el b/plz.el
index 23560bc4c8..fb9a4c742a 100644
--- a/plz.el
+++ b/plz.el
@@ -475,7 +475,12 @@ refer to rather than the current buffer's unparsed
headers."
(cl-loop while (re-search-forward (rx bol (group (1+ (not (in ":"))))
":" (1+ blank)
(group (1+ (not (in "\r\n")))))
limit t)
- collect (cons (match-string 1) (match-string 2))))))
+ ;; NOTE: Some HTTP servers send all-lowercase header keys,
which means an alist
+ ;; lookup with `equal' or `string=' fails when the case
differs. We don't want
+ ;; users to have to worry about this, so for consistency, we
downcase the
+ ;; header name. And while we're at it, we might as well intern
it so we can
+ ;; use `alist-get' without having to add "nil nil #'equal"
every time.
+ collect (cons (intern (downcase (match-string 1)))
(match-string 2))))))
(defun plz--narrow-to-body ()
"Narrow to body of HTTP response in current buffer."
diff --git a/tests/test-plz.el b/tests/test-plz.el
index 17070866e7..96adc12808 100644
--- a/tests/test-plz.el
+++ b/tests/test-plz.el
@@ -56,7 +56,7 @@
`(and (should (plz-response-p ,response))
(should (numberp (plz-response-version ,response)))
(should (eq 200 (plz-response-status ,response)))
- (should (equal "application/json" (alist-get "Content-Type"
(plz-response-headers ,response) nil nil #'equal)))
+ (should (equal "application/json" (alist-get 'content-type
(plz-response-headers ,response))))
(let* ((json (json-read-from-string (plz-response-body ,response)))
(headers (alist-get 'headers json))
(user-agent (alist-get 'User-Agent headers nil nil #'equal)))
- [elpa] externals/plz 950a5498cb 16/81: Tidy, (continued)
- [elpa] externals/plz 950a5498cb 16/81: Tidy, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 44e6f02064 17/81: Binary content, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 5bd683ead8 19/81: Tidy tests, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 3249835c8b 18/81: Tidy tests, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 21a7318f1c 26/81: Tests: Tidy/rename, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 3dd2598fe9 24/81: Tidy, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 3cc6747035 28/81: Meta: Add comm keyword, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 51404566fa 29/81: Notes: Add fetch.el, ELPA Syncer, 2022/05/11
- [elpa] externals/plz b77283748b 31/81: Meta: Update makem.sh, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 56c66c4421 32/81: Add/Change: :as 'binary, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 1bb701f1c1 36/81: Change/Fix: Downcase and intern header keys,
ELPA Syncer <=
- [elpa] externals/plz 6f8dfb83de 34/81: Tests: (plz-test-get-response) Change to macro, ELPA Syncer, 2022/05/11
- [elpa] externals/plz baf93bb80a 39/81: Fix: (plz--curl) Header args, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 33438b7105 35/81: CI: Enable testing of all branches, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 439fb383d9 37/81: Notes: Add idea about finalizers, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 65dbc0f219 41/81: Change/Fix: (plz--sentinel) Use exhaustive pcase, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 7eff40f276 44/81: Add: plz-finally, ELPA Syncer, 2022/05/11
- [elpa] externals/plz 27010c20e1 45/81: Meta: Update makem.sh, etc., ELPA Syncer, 2022/05/11
- [elpa] externals/plz f34efa052c 48/81: Fix: set-buffer-multibyte nil for binary, ELPA Syncer, 2022/05/11
- [elpa] externals/plz e977a046a3 50/81: Change: (plz-http-response-status-line-regexp) Match at BOL, ELPA Syncer, 2022/05/11
- [elpa] externals/plz f12f907719 52/81: Change/Fix: (plz--curl) Disable Expect header, ELPA Syncer, 2022/05/11