From 4d3fd23800ac2d09fe43f805b2231cc8a81f3ab1 Mon Sep 17 00:00:00 2001 From: lux Date: Fri, 9 Aug 2024 21:02:48 +0800 Subject: [PATCH] case-insensitive headers --- linux.jai | 10 ++++++---- windows.jai | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/linux.jai b/linux.jai index 4845715..81124fc 100644 --- a/linux.jai +++ b/linux.jai @@ -252,10 +252,12 @@ read_http_request :: (socket: Socket, thread_id: s32) -> *Request { kv := split(line, ": "); #if parseheaders table_add(*request.headers, kv[0], kv[1]); - if kv[0] == { - case "Content-Length"; request.content_length = xx to_integer(kv[1]); - case "Sec-WebSocket-Key"; request.websocket_key = kv[1]; - case "Accept-Encoding"; request.accept_encoding = kv[1]; + if compare_nocase(kv[0], "Content-Length") == 0 { + request.content_length = xx to_integer(kv[1]); + } else if compare_nocase(kv[0], "Sec-WebSocket-Key") == 0 { + request.websocket_key = kv[1]; + } else if compare_nocase(kv[0], "Accept-Encoding") == 0 { + request.accept_encoding = kv[1]; } if request.raw[request.buffercursor+2] == #char "\r" && request.raw[request.buffercursor+2 + 1] == #char "\n" { diff --git a/windows.jai b/windows.jai index 89be49f..137578e 100644 --- a/windows.jai +++ b/windows.jai @@ -224,9 +224,12 @@ recv_http_request :: (socket: MySocket) -> Request { kv := split(line, ": "); #if parseheaders table_add(*request.headers, kv[0], kv[1]); - if kv[0] == { - case "Content-Length"; request.content_length = xx to_integer(kv[1]); - case "Sec-WebSocket-Key"; request.websocket_key = kv[1]; + if compare_nocase(kv[0], "Content-Length") == 0 { + request.content_length = xx to_integer(kv[1]); + } else if compare_nocase(kv[0], "Sec-WebSocket-Key") == 0 { + request.websocket_key = kv[1]; + } else if compare_nocase(kv[0], "Accept-Encoding") == 0 { + request.accept_encoding = kv[1]; } if request.raw[buffercursor+2] == #char "\r" && request.raw[buffercursor+2 + 1] == #char "\n" {