From 2033101b3e9ca9fdc4efa8a658404594df67131f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 18:49:55 -0700 Subject: http: process Content-Length and Transfer-Encoding Explicitly track if our request will need Content-Length or chunked body decoding. --- ext/unicorn_http/ext_help.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ext/unicorn_http/ext_help.h') diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h index 19f08c9..5f7c296 100644 --- a/ext/unicorn_http/ext_help.h +++ b/ext/unicorn_http/ext_help.h @@ -26,4 +26,23 @@ static inline int str_cstr_eq(VALUE val, const char *ptr, size_t len) #define STR_CSTR_EQ(val, const_str) \ str_cstr_eq(val, const_str, sizeof(const_str) - 1) +/* strcasecmp isn't locale independent */ +static int str_cstr_case_eq(VALUE val, const char *ptr, size_t len) +{ + if (RSTRING_LEN(val) == len) { + const char *v = RSTRING_PTR(val); + + for (; len--; ++ptr, ++v) { + if ((*ptr == *v) || (*v >= 'A' && *v <= 'Z' && (*v | 0x20) == *ptr)) + continue; + return 0; + } + return 1; + } + return 0; +} + +#define STR_CSTR_CASE_EQ(val, const_str) \ + str_cstr_case_eq(val, const_str, sizeof(const_str) - 1) + #endif -- cgit v1.2.3-24-ge0c7