# mongrel-1.1.5 Documentation

Mongrel is a small library that provides a very fast HTTP 1.1 server for Ruby web applications. It is not particular to any framework, and is intended to be just enough to get a web application running behind a more complete and robust web server.

What makes Mongrel so fast is the careful use of an Ragel extension to provide fast, accurate HTTP 1.1 protocol parsing. This makes the server scream without too many portability issues.

See mongrel.rubyforge.org for more information.

## License

Mongrel is copyright 2007 Zed A. Shaw and contributors. It is licensed under the Ruby license and the GPL2. See the include LICENSE file for details.

## Quick Start

The easiest way to get started with Mongrel is to install it via RubyGems and then run a Ruby on Rails application. You can do this easily:

    $ gem install mongrel

Now you should have the mongrel_rails command available in your PATH, so just do the following:

    $ cd myrailsapp
    $ mongrel_rails start

This will start it in the foreground so you can play with it. It runs your application in production mode. To get help do:

    $ mongrel_rails start -h

Finally, you can then start in background mode:

    $ mongrel_rails start -d

And you can stop it whenever you like with:

    $ mongrel_rails stop

All of which should be done from your application's directory. It writes the PID of the process you ran into log/mongrel.pid.

There are also many more new options for configuring the rails runner including changing to a different directory, adding more MIME types, and setting processor threads and timeouts.

## Install

It doesn't explicitly require Camping, but if you want to run the examples/camping/ examples then you'll need to install Camping 1.2 at least (and redcloth I think). These are all available from RubyGems.

The library consists of a C extension so you'll need a C compiler or at least a friend who can build it for you.

Finally, the source includes a setup.rb for those who hate RubyGems.

## Usage

The examples/simpletest.rb file has the following code as the simplest example:

    require 'mongrel'

    class SimpleHandler < Mongrel::HttpHandler
       def process(request, response)
         response.start(200) do |head,out|
           head["Content-Type"] = "text/plain"
           out.write("hello!\n")
         end
       end
    end

    h = Mongrel::HttpServer.new("0.0.0.0", "3000")
    h.register("/test", SimpleHandler.new)
    h.register("/files", Mongrel::DirHandler.new("."))
    h.run.join

If you run this and access port 3000 with a browser it will say "hello!". If you access it with any url other than "/test" it will give a simple 404. Check out the Mongrel::Error404Handler for a basic way to give a more complex 404 message.

This also shows the DirHandler with directory listings. This is still rough but it should work for basic hosting. *File extension to mime type mapping is missing though.*

## Contact

E-mail the Mongrel list at rubyforge.org/mailman/listinfo/mongrel-users and someone will help you. Comments about the API are welcome.

## Files

- CHANGELOG
- COPYING
- LICENSE
- README
- Makefile

## Classes/Modules

- Mongrel
- Mongrel::CGIWrapper
- Mongrel::Camping
- Mongrel::Camping::CampingHandler
- Mongrel::Command
- Mongrel::Command::Base
- Mongrel::Command::Registry
- Mongrel::Configurator
- Mongrel::Const
- Mongrel::DeflateFilter
- Mongrel::DirHandler
- Mongrel::Error404Handler
- Mongrel::Gems
- Mongrel::HeaderOut
- Mongrel::HttpHandler
- Mongrel::HttpHandlerPlugin
- Mongrel::HttpParams
- Mongrel::HttpParser
- Mongrel::HttpParserError
- Mongrel::HttpRequest
- Mongrel::HttpResponse
- Mongrel::HttpServer
- Mongrel::Rails
- Mongrel::Rails::RailsConfigurator
- Mongrel::Rails::RailsHandler
- Mongrel::RedirectHandler
- Mongrel::StatisticsFilter
- Mongrel::Stats
- Mongrel::StatusHandler
- Mongrel::StopServer
- Mongrel::TimeoutError
- Mongrel::URIClassifier
- Mongrel::URIClassifier::RegistrationError
- Mongrel::URIClassifier::UsageError
- RequestLog
- RequestLog::Access
- RequestLog::Files
- RequestLog::Objects
- RequestLog::Params
- RequestLog::Threads
- IO
- Kernel
- MongrelDbg
- TCPServer

## Methods

- ::add_mime_type — Mongrel::DirHandler
- ::begin_trace — MongrelDbg
- ::configure — MongrelDbg
- ::end_trace — MongrelDbg
- ::escape — Mongrel::HttpRequest
- ::new — Mongrel::Camping::CampingHandler
- ::new — Mongrel::Command::Base
- ::new — Mongrel::Stats
- ::new — Mongrel::HttpParser
- ::new — Mongrel::HttpResponse
- ::new — Mongrel::HttpHandlerPlugin
- ::new — Mongrel::HttpServer
- ::new — Mongrel::HttpRequest
- ::new — Mongrel::Error404Handler
- ::new — Mongrel::Configurator
- ::new — Mongrel::RedirectHandler
- ::new — Mongrel::StatusHandler
- ::new — Mongrel::URIClassifier
- ::new — Mongrel::StatisticsFilter
- ::new — Mongrel::DeflateFilter
- ::new — Mongrel::CGIWrapper
- ::new — Mongrel::Rails::RailsHandler
- ::new — Mongrel::DirHandler
- ::new — Mongrel::HeaderOut
- ::query_parse — Mongrel::HttpRequest
- ::require — Mongrel::Gems
- ::start — Mongrel::Camping
- ::trace — MongrelDbg
- ::tracing? — MongrelDbg
- ::unescape — Mongrel::HttpRequest
- #[]= — Mongrel::HeaderOut
- #args — Mongrel::CGIWrapper
- #can_serve — Mongrel::DirHandler
- #change_privilege — Mongrel::Configurator
- #cloaker — Mongrel::Configurator
- #cloaking_class — Mongrel::Configurator
- #close — IO
- #commands — Mongrel::Command::Registry
- #configure — Mongrel::Command::Base
- #configure_socket_options — Mongrel::HttpServer
- #daemonize — Mongrel::Configurator
- #debug — Mongrel::Configurator
- #describe_listener — Mongrel::StatusHandler
- #done — Mongrel::HttpResponse
- #done= — Mongrel::HttpResponse
- #dump — Mongrel::Stats
- #dump — Mongrel::StatisticsFilter
- #env_table — Mongrel::CGIWrapper
- #error? — Mongrel::HttpParser
- #execute — Mongrel::HttpParser
- #failure — Mongrel::Command::Base
- #finish — Mongrel::HttpParser
- #finished — Mongrel::HttpResponse
- #finished? — Mongrel::HttpParser
- #graceful_shutdown — Mongrel::HttpServer
- #header — Mongrel::CGIWrapper
- #help — Mongrel::Command::Base
- #initialize — TCPServer
- #initialize_with_backlog — TCPServer
- #initialize_without_backlog — TCPServer
- #join — Mongrel::Configurator
- #listener — Mongrel::Configurator
- #load_mime_map — Mongrel::Configurator
- #load_plugins — Mongrel::Configurator
- #load_yaml — Mongrel::Configurator
- #log — Mongrel::Configurator
- #log_open_files — Kernel
- #mean — Mongrel::Stats
- #nread — Mongrel::HttpParser
- #open — Kernel
- #open — IO
- #options — Mongrel::Command::Base
- #orig_close — IO
- #orig_open — Kernel
- #orig_open — IO
- #out — Mongrel::CGIWrapper
- #plugin — Mongrel::Configurator
- #print_command_list — Mongrel::Command::Registry
- #process — RequestLog::Threads
- #process — Mongrel::StatusHandler
- #process — Mongrel::DeflateFilter
- #process — Mongrel::DirHandler
- #process — Mongrel::Error404Handler
- #process — Mongrel::HttpHandler
- #process — Mongrel::RedirectHandler
- #process — RequestLog::Params
- #process — RequestLog::Objects
- #process — Mongrel::Camping::CampingHandler
- #process — Mongrel::Rails::RailsHandler
- #process — RequestLog::Files
- #process — RequestLog::Access
- #process — Mongrel::StatisticsFilter
- #process — Mongrel::HttpHandlerPlugin
- #process_client — Mongrel::HttpServer
- #rails — Mongrel::Rails::RailsConfigurator
- #read_body — Mongrel::HttpRequest
- #read_socket — Mongrel::HttpRequest
- #reap_dead_workers — Mongrel::HttpServer
- #redirect — Mongrel::Configurator
- #register — Mongrel::URIClassifier
- #register — Mongrel::HttpServer
- #reload! — Mongrel::Rails::RailsHandler
- #reload! — Mongrel::Rails::RailsConfigurator
- #remove_pid_file — Mongrel::Configurator
- #request_begins — Mongrel::HttpHandlerPlugin
- #request_begins — Mongrel::HttpHandler
- #request_progress — Mongrel::HttpHandlerPlugin
- #request_progress — Mongrel::HttpHandler
- #reset — Mongrel::HttpResponse
- #reset — Mongrel::HttpParser
- #reset — Mongrel::Stats
- #resolve — Mongrel::URIClassifier
- #resolve_defaults — Mongrel::Configurator
- #run — Mongrel::Command::Registry
- #run — Mongrel::Configurator
- #run — Mongrel::Command::Base
- #run — Mongrel::HttpServer
- #run_config — Mongrel::Configurator
- #sample — Mongrel::Stats
- #sd — Mongrel::Stats
- #send_body — Mongrel::HttpResponse
- #send_cookies — Mongrel::CGIWrapper
- #send_dir_listing — Mongrel::DirHandler
- #send_file — Mongrel::DirHandler
- #send_file — Mongrel::HttpResponse
- #send_header — Mongrel::HttpResponse
- #send_status — Mongrel::HttpResponse
- #setup_rails_signals — Mongrel::Rails::RailsConfigurator
- #setup_signals — Mongrel::Configurator
- #socket_error — Mongrel::HttpResponse
- #start — Mongrel::HttpResponse
- #status — Mongrel::CGIWrapper
- #stdinput — Mongrel::CGIWrapper
- #stdoutput — Mongrel::CGIWrapper
- #stop — Mongrel::Configurator
- #stop — Mongrel::HttpServer
- #table — Mongrel::StatusHandler
- #tick — Mongrel::Stats
- #to_s — Mongrel::Stats
- #unregister — Mongrel::HttpServer
- #unregister — Mongrel::URIClassifier
- #uri — Mongrel::Configurator
- #uris — Mongrel::URIClassifier
- #valid? — Mongrel::Command::Base
- #valid_dir? — Mongrel::Command::Base
- #valid_exists? — Mongrel::Command::Base
- #valid_file? — Mongrel::Command::Base
- #valid_group? — Mongrel::Command::Base
- #valid_user? — Mongrel::Command::Base
- #validate — Mongrel::Command::Base
- #write — Mongrel::HttpResponse
- #write_pid_file — Mongrel::Configurator

[Validate]

Generated with the Darkfish Rdoc Generator 2.