# \[ANN\] Mongrel HTTP Library 0.2.2 (Serving Directories)

**URL:** <https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562>\
**Category:** Rails\
**Created:** [February 3, 2006, 8:21am UTC](https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562 "2006-02-03T08:21:56Z")\
**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 3, 2006, 8:21am UTC](https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562/1 "2006-02-03T08:21:56Z")

</div>

Hey Folks,

Another announcement of Mongrel – the fastest little web server  
library for Ruby yet. This release is nice in that it should build  
on win32 better and it now sports a small DirHandler that can serve  
directories and files. This means Mongrel is closer to replacing  
WEBrick as a Rails debug runner.

You can get the releases and information from:

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

== Install and Upgrade

People who use(d) RubyGems can simply do:

gem install mongrel

-or-

gem upgrade

And they’ll get the new gear. You can go back to the project page  
and download the source .tgz if you installed using that.

== Changes

- Fixed a header so that win32 folks can build it.
- Added all CGI parameters that didn’t cause security or performance  
problems.
- Forced the sockets to not do reverse name lookup (huge performance  
hit for little benefit).
- Created a REQUEST\_URI parameter that has the original untouched URI  
used in the request. This is the string used to lookup the handlers  
and create the SCRIPT\_NAME and PATH\_INFO parameters.
- Implemented a basic directory serving handler called DirHandler.  
It will serve files in a directory, print a simple directory listing,  
and tries to protect against malicious path requests.
- Some minor code clean-ups and additional documentation regarding  
constants used.

== The DirHandler

The really simple DirHandler is used like this (from the examples/  
simpletest.rb file):

h = Mongrel::HttpServer.new(“0.0.0.0”, “3000”)  
h.register(“/files”, Mongrel::DirHandler.new(“.”))  
h.run.join

This simply sets things up so that when people go to /files, they get  
the contents of the current directory. The DirHandler expands the  
path you give it so that when requests come in, it can expand them  
too and make sure that both paths have the same prefix. If not it  
will reject them. There is also an option to turn off the directory  
listings using the second parameter to DirHandler.new().

This initial file serving is very simplistic since it doesn’t map  
extensions to mime types yet. It should be a good start for some  
people though.

== Feedback

Thanks for all the feedback and bug reports so far. With directory  
serving and complete CGI parameters out of the way I’m going to start  
working on a Rails runner using Mongrel next, and possibly a caching  
system. Goal for the weekend will be to get a Rails application  
running in Mongrel standalone.

Enjoy!

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 4, 2006, 1:17am UTC](https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562/2 "2006-02-04T01:17:38Z")

</div>

So, to clarify for us windows types, if I run

gem install mongrel

on my windows box, I still need to find someone with a MicroSoft C  
compiler  
to build it before I can use it ??

Is that right?  
-Larry

On 2/2/06, Zed S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - Forced the sockets to not do reverse name lookup (huge performance  
> == The DirHandler  
> path you give it so that when requests come in, it can expand them
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson

---

<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 4, 2006, 1:35am UTC](https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562/3 "2006-02-04T01:35:51Z")

</div>

Yes, I’m going to try building pre-compiled gems for win32 and OSX  
this weekend (to coincide with the next release).

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 4, 2006, 2:08pm UTC](https://www.ruby-forum.com/t/ann-mongrel-http-library-0-2-2-serving-directories/100562/4 "2006-02-04T14:08:17Z")

</div>

That sounds wonderfull. I love you’re agressive release cycle!  
-Larry

On 2/3/06, Zed S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Best Regards,  
-Larry  
“Work, work, work…there is no satisfactory alternative.”  
— E.Taft Benson
