about summary refs log tree commit homepage
path: root/examples
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-05-23 06:40:24 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-05-23 06:40:24 +0000
commite6e7c3a058e38db93330c68ebea9564c753075b6 (patch)
treec1b34fb6c7da42aab988f2ccea222e45dae2f515 /examples
parent2499218abf60d1afcf203cf81633e3b61eaa4688 (diff)
downloadunicorn-e6e7c3a058e38db93330c68ebea9564c753075b6.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@208 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'examples')
-rw-r--r--examples/simpletest.rb22
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/simpletest.rb b/examples/simpletest.rb
index fbad8f4..8ac2e98 100644
--- a/examples/simpletest.rb
+++ b/examples/simpletest.rb
@@ -1,22 +1,16 @@
+$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
 require 'mongrel'
 require 'yaml'
 require 'zlib'
 
 class SimpleHandler < Mongrel::HttpHandler
-    def process(request, response)
-      response.start do |head,out|
-        head["Content-Type"] = "text/html"
-        results = "<html><body>Your request:<br /><pre>#{request.params.to_yaml}</pre><a href=\"/files\">View the files.</a></body></html>"
-        if request.params["HTTP_ACCEPT_ENCODING"] == "gzip,deflate"
-          head["Content-Encoding"] = "deflate"
-          # send it back deflated
-          out << Zlib::Deflate.deflate(results)
-        else
-          # no gzip supported, send it back normal
-          out << results
-        end
-      end
+  def process(request, response)
+    response.start do |head,out|
+      head["Content-Type"] = "text/html"
+      results = "<html><body>Your request:<br /><pre>#{request.params.to_yaml}</pre><a href=\"/files\">View the files.</a></body></html>"
+      out << results
     end
+  end
 end
 
 class DumbHandler < Mongrel::HttpHandler
@@ -37,7 +31,9 @@ end
 config = Mongrel::Configurator.new :host => ARGV[0], :port => ARGV[1] do
   listener do
     uri "/", :handler => SimpleHandler.new
+    uri "/", :handler => Mongrel::DeflateFilter.new
     uri "/dumb", :handler => DumbHandler.new
+    uri "/dumb", :handler => Mongrel::DeflateFilter.new
     uri "/files", :handler => Mongrel::DirHandler.new(ARGV[2])
   end