From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Zed A. Shaw" Newsgroups: gmane.comp.lang.ruby.mongrel.devel Subject: Re: Pure Ruby HTTP parser Date: Tue, 6 May 2008 02:27:29 -0400 Message-ID: <20080506022729.f0db321e.zedshaw@zedshaw.com> References: <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34@mail.gmail.com> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1210055209 32244 80.91.229.12 (6 May 2008 06:26:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 May 2008 06:26:49 +0000 (UTC) To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue May 06 08:27:24 2008 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org In-Reply-To: <3ae7f4480804240438g62ed7190if2a84ff08dd2fe34-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.8; x86_64-unknown-linux-gnu) X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.10 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.mongrel.devel:53 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1JtGe3-00009s-Hs for gclrmd-mongrel-development@m.gmane.org; Tue, 06 May 2008 08:27:23 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id B9FDF18585B1; Tue, 6 May 2008 02:26:38 -0400 (EDT) Received: from mail.zedshaw.com (67-207-134-146.slicehost.net [67.207.134.146]) by rubyforge.org (Postfix) with ESMTP id A9DB318585C8 for ; Tue, 6 May 2008 02:26:26 -0400 (EDT) Received: from gw.localhost (localhost [127.0.0.1]) by mail.zedshaw.com (Postfix) with SMTP id 4CA131C0112 for ; Mon, 5 May 2008 23:26:26 -0700 (PDT) List-Post: 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/