[ANN] Mongrel HTTP Library 0.2.1 (Fancy URI Matching)

And now it’s time for yet another Mongrel release.

Mongrel is a small fast HTTP library written in (partly) Ruby. It is
intended to be used by web app framework authors to make their
applications fast and deployable without resorting to SCGI/FastCGI
trickery. Mongrel is tested to work on Linux and Mac OS X (with more
reports welcome). You’ll need a full compiler to install Mongrel
since it has a C extension to work the voodoo.

You can grab downloads on the project page’s File tab, or you can do
a simple:

gem install mongrel

To get the latest stuff via RubyGems. As usual you can also grab the
source .tgz and build from scratch if you need. People with mongrel
already installed can just gem update.

== Rails

A few people have been asking when Rails will run under Mongrel. I
used Why’s Camping Framework to test out Mongrel for serving a web
app since people were willing to just jump in and help. The Og+Nitro
folks stepped up and apparently already have Mongrel worked into
their source tree. It looks like people are taking the initiative
which is great.

Since I’m probably the most qualified dude to do this for Rails it
looks like the Rails folks may have to wait a bit while I get Mongrel
tight and more functional. End result should be that everyone is all
happy and fast sooner than later, but don’t think that I’m ignoring
Rails on purpose. It’ll come.

== Changes

This release is pretty simple:

  • Fixed a few bugs people reported.
  • Cleaned up some documentation that people called “juvenile”.
  • And then redesigned the Trie search so that it finds any handler at
    any character in any URI in one search.
  • Wrote more extensive tests for the URIClassifier to test out the
    new Trie implementation.

This change lays the foundation for pretty much everything I need to
start adding the important components many web application frameworks
need. First up will be the ability to serve files, directories,
cache results, and efficiently upload/receive files.

== The New URIClassifier

The URIClassifier now lets you attach HttpHandlers (well, any object
really) to any URI at pretty much any point. For the majority of
cases people will just attach a few URIs like this:

h = Mongrel::HttpServer.new(“”, “3000”)
h.register("/test", SimpleHandler.new)

Which is the way things always worked anyhow. The big change though
is that you can load up handlers at any individual character, and the
longest match wins. So, you can even do this (in theory):

h.register("/test;mystuff;thosestuffs", WeirdHandler.new)

The main advantage of this is that the URIClassifier doesn’t actually
parse the URI, it just uses the trie to find the longest prefix with
a handler. I’m sure people will find bizarre uses for this.

Also, registering and unregistering is pretty fast. The tradeoff
with this is that you’ll use more memory than you would with just a

== Testing

Please test this out and shoot me e-mails with bug reports. Better
yet, use the http://rubyforge.org/projects/mongrel/ tracker if you
can. I like lists.

Zed A. Shaw

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs