diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-08-02 18:49:55 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-08-09 01:30:16 -0700 |
commit | 2033101b3e9ca9fdc4efa8a658404594df67131f (patch) | |
tree | c3ede7c5f2287d1061d5c61a179bee19e8d70d68 /ext/unicorn_http/ext_help.h | |
parent | 60b4397f51894d5e679a6eed73a8cde957f03c4a (diff) | |
download | unicorn-2033101b3e9ca9fdc4efa8a658404594df67131f.tar.gz |
Explicitly track if our request will need Content-Length or chunked body decoding.
Diffstat (limited to 'ext/unicorn_http/ext_help.h')
-rw-r--r-- | ext/unicorn_http/ext_help.h | 19 |
1 files changed, 19 insertions, 0 deletions
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 |