# Mongrel 0.2.1 HTTP Library (Fancy URI Matching)

**URL:** <https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233>\
**Category:** Ruby\
**Created:** [February 2, 2006, 8:27am UTC](https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233 "2006-02-02T08:27:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [February 2, 2006, 8:27am UTC](https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233/1 "2006-02-02T08:27:50Z")

</div>

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.

- [http://rubyforge.org/projects/mongrel/](http://rubyforge.org/projects/mongrel/) – project page.
- [http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/) – lame RDoc as home page.

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.

== 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(“0.0.0.0”, “3000”)  
h.register(“/test”, SimpleHandler.new)  
h.run.join

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  
Hash.

== Testing

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

Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [February 2, 2006, 2:29pm UTC](https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233/2 "2006-02-02T14:29:32Z")

</div>

Please, add

#if defined(\_WIN32)  
#include \<stddef.h\>  
#endif

in http11\_parser.h for fine compilation on win32 platform (vc toolkit  
2003), required for size\_t definition

Massimo Maria Ghisalberti  
LINee multimediaagency

> **[linee.it - This website is for sale! - linee Resources...](http://www.linee.it)**
>
> This website is for sale! linee.it is your first and best source for all of the information you’re looking for. From general topics to more of what you would expect to find here, linee.it has it all. We hope you find what you are searching for!

[http://www.mammuth.it](http://www.mammuth.it)  
[http://nissl.deviantart.com](http://nissl.deviantart.com)

[removed\_email\_address@domain.invalid]  
[removed\_email\_address@domain.invalid]  
[removed\_email\_address@domain.invalid]  
[removed\_email\_address@domain.invalid]  
(removed\_email\_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [February 2, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233/3 "2006-02-02T19:35:19Z")

</div>

Done. I’ll post a 0.2.2 tonight with this and some other improvements.

BTW, could you describe to me your win32 build setup so that I can try  
building it too?

Zed

---

<div class="post-metadata">

**Author:** ![Zed\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/da6949/32.png) [@Zed\_S](https://www.ruby-forum.com/u/Zed_S)\
**Post date:** [February 2, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/mongrel-0-2-1-http-library-fancy-uri-matching/100233/4 "2006-02-02T22:03:28Z")

</div>

simply add

#if defined(\_MSC\_VER)  
#include \<stddef.h\>  
#endif

to your header http11\_parser.h and run extconf.rb for makefile  
generation or from the top folder setup.rb for building and install.

\_MSC\_VER for testing microsoft compiler, \_WIN32 is more generic for  
platform.

🙂
