Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dmmulroy committed Mar 19, 2024
1 parent c266652 commit ebd05d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/gleam/http/request.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ pub fn from_uri(uri: Uri) -> Result(Request(String), Nil) {
/// If the request does not have that header then `Error(Nil)` is returned.
///
pub fn get_header(request: Request(body), key: String) -> Result(String, Nil) {
let lowercased_key = string.lowercase(key)
use #(_, value) <- result.try(
list.find(request.headers, fn(header) {
string.lowercase(header.0) == string.lowercase(key)
string.lowercase(header.0) == lowercased_key
}),
)
Ok(value)
Expand Down
2 changes: 1 addition & 1 deletion test/gleam/http/request_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn get_req_case_insensitive_header_test() {
)
}

let header_key = "GLEAM"
let header_key = "gleam"
let request = make_request([#("ANSWER", "42"), #("GLEAM", "awesome")])
request
|> request.get_header(header_key)
Expand Down

0 comments on commit ebd05d6

Please sign in to comment.