Browse Source

rack plaintext test

Patrick Falls 12 years ago
parent
commit
4c49fa3cef
3 changed files with 18 additions and 7 deletions
  1. 3 1
      rack/benchmark_config
  2. 14 5
      rack/config.ru
  3. 1 1
      rack/config/unicorn.rb

+ 3 - 1
rack/benchmark_config

@@ -4,14 +4,16 @@
     "ruby": {
       "setup_file": "setup_ruby",
       "json_url": "/json",
+      "plaintext_url": "/plaintext",
       "port": 8080,
       "sort": 14
     },
     "jruby": {
       "setup_file": "setup_jruby",
       "json_url": "/rack/json",
+      "plaintext_url": "/rack/plaintext",
       "port": 8080,
       "sort": 15
     }
   }]
-}
+}

+ 14 - 5
rack/config.ru

@@ -1,10 +1,19 @@
 require 'json'
 
 app = lambda do |env| 
-  [
-    200,
-    { 'Content-Type' => 'application/json' },
-    [{:message => "Hello World!"}.to_json]
-  ]
+  if env['PATH_INFO'] == "/plaintext"
+    [
+      200,
+      { 'Content-Type' => 'text/plain' },
+      ["Hello, World!"]
+    ]
+  else
+    [
+      200,
+      { 'Content-Type' => 'application/json' },
+      [{:message => "Hello World!"}.to_json]
+    ]
+  end
 end 
 run app 
+

+ 1 - 1
rack/config/unicorn.rb

@@ -1,5 +1,5 @@
 worker_processes 8
-listen "/tmp/.sock", :backlog => 256
+listen "/tmp/.sock", :backlog => 4096
 
 preload_app true
 GC.respond_to?(:copy_on_write_friendly=) and