From 2ef75057cd39dd013db9bac1ee7ef70b4cbe8f0b Mon Sep 17 00:00:00 2001 From: Oleg Golosovskiy Date: Tue, 4 Oct 2011 20:20:14 +0800 Subject: [PATCH] http charsets have case insensitive tokens Andy, According http://www.ietf.org/rfc/rfc2616.txt HTTP character sets are identified by case-insensitive tokens. Please replase if (strcmp(lws_tokens[n].token, wsi->name_buffer)) continue; to if (stricmp(lws_tokens[n].token, wsi->name_buffer)) continue; Oleg Also introduce strcasecmp definition for win32 Signed-off-by: Oleg Golosovskiy --- lib/libwebsockets.h | 2 ++ lib/parsers.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index cab2eb3b..bb414286 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -37,6 +37,8 @@ extern "C" { #include "gettimeofday.h" +#define strcasecmp stricmp + #ifdef LWS_DLL #ifdef LWS_INTERNAL #define LWS_EXTERN extern __declspec(dllexport) diff --git a/lib/parsers.c b/lib/parsers.c index 01d360b8..fb363237 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -179,7 +179,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c) for (n = 0; n < WSI_TOKEN_COUNT; n++) { if (wsi->name_buffer_pos != lws_tokens[n].token_len) continue; - if (strcmp(lws_tokens[n].token, wsi->name_buffer)) + if (strcasecmp(lws_tokens[n].token, wsi->name_buffer)) continue; debug("known hdr '%s'\n", wsi->name_buffer); wsi->parser_state = WSI_TOKEN_GET_URI + n;