http charsets have case insensitive tokens
authorOleg Golosovskiy <ogolosovskiy@unison.com>
Tue, 4 Oct 2011 12:20:14 +0000 (20:20 +0800)
committerAndy Green <andy@warmcat.com>
Tue, 4 Oct 2011 12:20:14 +0000 (20:20 +0800)
 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 <ogolosovskiy@unison.com>
lib/libwebsockets.h
lib/parsers.c

index cab2eb3..bb41428 100644 (file)
@@ -37,6 +37,8 @@ extern "C" {
 
 #include "gettimeofday.h"
 
+#define strcasecmp stricmp
+
 #ifdef LWS_DLL
 #ifdef LWS_INTERNAL
 #define LWS_EXTERN extern __declspec(dllexport)
index 01d360b..fb36323 100644 (file)
@@ -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;