News for hackers. Stuff that matters.
Re:Mongrel2 1.0 released. by zedshaw on Thursday September 02, 2010 @12:03PM (#1656604)
As long as you don't get into the algorithms it's pretty simple.

A hand written http parser is kind of like writing a "white-list" of what the server rejects. Since there's no algorithm backing it the only thing you can do is list out all the things you can think of or have run into that is "wrong".

Using a parser (well lexer really) like Ragel I can make something that's relaxed, but it's more of a white-list of what it accepts. The algorithm explictily says this particular set of characters in this grammar is all that I'll answer to.

If you then write the grammar so that it handles 99% of the requests you run into in the wild, you get the same relaxed quality as a hand written one, but it explicitly drops the 1% that are invalid or usually hacks.

This is also the same parser that's power a large number of web servers in multiple languages, so it's proven to work.

Re:Mongrel2 1.0 released. by points on Friday September 03, 2010 @07:51AM (#1659251)
My mind is still boggling over how you make a simple HTTP request parser so complex sounding.
Re:Mongrel2 1.0 released. by shoover on Friday September 03, 2010 @09:36AM (#1659475)
Take a look at the Mongrel/Mongrel2 Ragel grammar and compare it to a hand-written request parser. You might be surprised which is complex.
Re:Mongrel2 1.0 released. by points on Friday September 03, 2010 @01:58PM (#1660447)
Yeah I just did. Mongrel2 looks overly complex. But then it is C...