diff options
author | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:20 +0000 |
---|---|---|
committer | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:20 +0000 |
commit | 094e419ce649632d4cff8be3848f2b8d395cb9ba (patch) | |
tree | a1b269f6ba877c9bcc86e5f7f16459b04ddd06d8 /ext/http11/http11.c | |
parent | 6b981f388abd352f57c984818a26182af56b1f6d (diff) | |
download | unicorn-094e419ce649632d4cff8be3848f2b8d395cb9ba.tar.gz |
This is based on Zed's suggestion and helps take complexity out of the hand-written C code, allowing memcpy() to be used instead. Zed Shaw wrote in <20080303044659.5a550c19.zedshaw@zedshaw.com>: > * Also, now that I think about it, if you don't care that the original > string is modified in place then you can just have ragel do all of this > as it goes. Simply modify the parser to have it do this transform on > the header chars using the existing pointer. That'd probably be > alright since people don't usually keep the input headers around when > using the mongrel parser. I don't have a working Java runtime, so I've only made the bare minimum modification to the http11_parser.java.rl file which allows Ragel to still work with it. All the other Java parts are untouched and whatever upper-casing routine was used before continues to be used now. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@990 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext/http11/http11.c')
-rw-r--r-- | ext/http11/http11.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/ext/http11/http11.c b/ext/http11/http11.c index 3cb6697..1e028ee 100644 --- a/ext/http11/http11.c +++ b/ext/http11/http11.c @@ -68,8 +68,6 @@ DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32))); void http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen) { - char *ch; - const char *fch; VALUE req = (VALUE)data; VALUE v = Qnil; VALUE f = Qnil; @@ -90,13 +88,7 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s memcpy(RSTRING_PTR(f), RSTRING_PTR(global_http_prefix), RSTRING_LEN(global_http_prefix)); - - ch = RSTRING_PTR(f) + RSTRING_LEN(global_http_prefix); - for(fch = field; flen-- != 0; ++fch) { - *ch++ = (*fch >= 'a' && *fch <= 'z') ? - ASCII_UPCASE_CHAR(*fch) : - (*fch == '-' ? '_' : *fch); - } + memcpy(RSTRING_PTR(f) + RSTRING_LEN(global_http_prefix), field, flen); rb_hash_aset(req, f, v); } |