<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,7 +5,81 @@ module Rack
   module Handler
     class Mongrel &lt; ::Mongrel::HttpHandler
       def self.run(app, options={})
-        ::Mongrel.run(app, options)
+        if ::Mongrel.respond_to?(:run)
+          ::Mongrel.run(app, options)
+        else
+          server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0',
+                                             options[:Port] || 8080)
+          # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.
+          # Use is similar to #run, replacing the app argument with a hash of
+          # { path=&gt;app, ... } or an instance of Rack::URLMap.
+          if options[:map]
+            if app.is_a? Hash
+              app.each do |path, appl|
+                path = '/'+path unless path[0] == ?/
+                server.register(path, Rack::Handler::Mongrel.new(appl))
+              end
+            elsif app.is_a? URLMap
+              app.instance_variable_get(:@mapping).each do |(host, path, appl)|
+                next if !host.nil? &amp;&amp; !options[:Host].nil? &amp;&amp; options[:Host] != host
+              path = '/'+path unless path[0] == ?/
+              server.register(path, Rack::Handler::Mongrel.new(appl))
+              end
+            else
+              raise ArgumentError, &quot;first argument should be a Hash or URLMap&quot;
+            end
+          else
+            server.register('/', Rack::Handler::Mongrel.new(app))
+          end
+          yield server if block_given?
+          server.run.join
+        end
+      end
+
+      def initialize(app)
+        @app = app
+      end
+ 
+      def process(request, response)
+        env = {}.replace(request.params)
+        env.delete &quot;HTTP_CONTENT_TYPE&quot;
+        env.delete &quot;HTTP_CONTENT_LENGTH&quot;
+ 
+        env[&quot;SCRIPT_NAME&quot;] = &quot;&quot; if env[&quot;SCRIPT_NAME&quot;] == &quot;/&quot;
+ 
+        env.update({&quot;rack.version&quot; =&gt; [0,1],
+                     &quot;rack.input&quot; =&gt; request.body || StringIO.new(&quot;&quot;),
+                     &quot;rack.errors&quot; =&gt; $stderr,
+ 
+                     &quot;rack.multithread&quot; =&gt; true,
+                     &quot;rack.multiprocess&quot; =&gt; false, # ???
+                     &quot;rack.run_once&quot; =&gt; false,
+ 
+                     &quot;rack.url_scheme&quot; =&gt; &quot;http&quot;,
+                   })
+        env[&quot;QUERY_STRING&quot;] ||= &quot;&quot;
+        env.delete &quot;PATH_INFO&quot; if env[&quot;PATH_INFO&quot;] == &quot;&quot;
+ 
+        status, headers, body = @app.call(env)
+ 
+        begin
+          response.status = status.to_i
+          response.send_status(nil)
+ 
+          headers.each { |k, vs|
+            vs.each { |v|
+              response.header[k] = v
+            }
+          }
+          response.send_header
+ 
+          body.each { |part|
+            response.write part
+            response.socket.flush
+          }
+        ensure
+          body.close if body.respond_to? :close
+        end
       end
     end
   end</diff>
      <filename>lib/rack/handler/mongrel.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>59bf11fee68e3c3eba97dec5db1fb98e76c58698</id>
    </parent>
  </parents>
  <author>
    <name>Ian Ownbey</name>
    <email>ian@inspir.es</email>
  </author>
  <url>http://github.com/iownbey/rack/commit/c79375a61c34b96d8ad428485b7a010376d63f85</url>
  <id>c79375a61c34b96d8ad428485b7a010376d63f85</id>
  <committed-date>2009-01-31T21:46:04-08:00</committed-date>
  <authored-date>2009-01-31T21:46:04-08:00</authored-date>
  <message>Made mongrel handler backwards compatable</message>
  <tree>1fde4091d94269374624deea7ad4beba2c8ceca3</tree>
  <committer>
    <name>Ian Ownbey</name>
    <email>ian@inspir.es</email>
  </committer>
</commit>
