forked from ring-clojure/ring
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected lookup of mixed-case headers.
Apparently this is temporary solution. Perhaps a better one would be to put lower-case headers in all cases (and maybe then convert them to Camel-Case in ring adapter)
- Loading branch information
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns ring.util.headers) | ||
|
||
(defn get-header | ||
"Get request or response header by name. | ||
Lookup is case-insensitive" | ||
[message header-name] | ||
(let [normalized-name (.toLowerCase header-name)] | ||
(-> (filter | ||
#(= (-> % first .toLowerCase) normalized-name) | ||
(:headers message)) | ||
first | ||
second))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns ring.util.test.headers | ||
(:use ring.util.headers | ||
clojure.test)) | ||
|
||
(deftest test-get-header | ||
(is (= "a" (get-header {:headers {"Some-Header" "a"}} "some-header"))) | ||
(is (nil? (get-header {:headers {"Same-Hero" "a"}} "some-header")))) |