From zedshaw at zedshaw.com Tue May 6 02:27:29 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Tue, 6 May 2008 02:27:29 -0400 Subject: [Mongrel-development] Pure Ruby HTTP parser In-Reply-To: <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34@mail.gmail.com> References: <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34@mail.gmail.com> Message-ID: <20080506022729.f0db321e.zedshaw@zedshaw.com> On Thu, 24 Apr 2008 13:38:03 +0200 "ry dahl" wrote: > One could replace http11's parser with some regular expressions and > out-of-bounds checking rather easily. I think Kirk Haines did this (?) > and said it was rather comparable in speed to the C/Ragel state > machine. I guess that wasn't really the point of your exercise, but > it's worth noting, if anyone actually wants a pure ruby http parser. Yes, fast, but not correct. The main difference between a generated parser based on algorithms and hand crafted regex is when the parser blows up it says: "Syntax error at character #34 expecting BLAH, FOO, and BAR symbols." Regexen do this: "Hi, oh thanks, I *love* hacks like this. You crafted this shellcode really well so that it looks mildly like a payload. Super awesome I'll just pass this vaguely HTTP string right on to our app." :-) -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/