Skip to content

Commit b80c5f9

Browse files
sam-tomburyc-cube
authored andcommitted
fix: make check for 'Connection: Upgrade' header case-insensitive
Some clients send lowercase 'upgrade' as value (matching typical keep-alive behaviour)
1 parent d38eb85 commit b80c5f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/server.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,11 @@ let find_map f l =
311311
in
312312
aux f l
313313
314-
let string_as_list_contains_ (s : string) (sub : string) : bool =
314+
let header_list_contains_ (s : string) (name : string) : bool =
315+
let name' = String.lowercase_ascii name in
315316
let fragments = String.split_on_char ',' s in
316-
List.exists (fun fragment -> String.trim fragment = sub) fragments
317+
List.exists (fun fragment ->
318+
String.lowercase_ascii (String.trim fragment) = name') fragments
317319
318320
(* handle client on [ic] and [oc] *)
319321
let client_handle_for (self : t) ~client_addr ic oc : unit =
@@ -379,7 +381,7 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
379381
380382
(* check headers *)
381383
(match Request.get_header req "connection" with
382-
| Some str when string_as_list_contains_ str "Upgrade" -> ()
384+
| Some str when header_list_contains_ str "Upgrade" -> ()
383385
| _ -> bad_reqf 426 "connection header must contain 'Upgrade'");
384386
(match Request.get_header req "upgrade" with
385387
| Some u when u = UP.name -> ()

0 commit comments

Comments
 (0)