thin 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. data/CHANGELOG +8 -0
  2. data/README.md +83 -0
  3. data/Rakefile +9 -32
  4. data/example/vlad.rake +1 -1
  5. data/lib/rack/adapter/loader.rb +0 -16
  6. data/lib/thin.rb +22 -24
  7. data/lib/thin/backends/base.rb +3 -1
  8. data/lib/thin/connection.rb +9 -8
  9. data/lib/thin/daemonizing.rb +3 -1
  10. data/lib/thin/logging.rb +1 -1
  11. data/lib/thin/runner.rb +36 -36
  12. data/lib/thin/server.rb +13 -0
  13. data/lib/thin/version.rb +3 -3
  14. metadata +5 -91
  15. data/README +0 -69
  16. data/benchmark/abc +0 -51
  17. data/benchmark/benchmarker.rb +0 -80
  18. data/benchmark/runner +0 -82
  19. data/spec/backends/swiftiply_client_spec.rb +0 -66
  20. data/spec/backends/tcp_server_spec.rb +0 -33
  21. data/spec/backends/unix_server_spec.rb +0 -37
  22. data/spec/command_spec.rb +0 -25
  23. data/spec/configs/cluster.yml +0 -9
  24. data/spec/configs/single.yml +0 -9
  25. data/spec/connection_spec.rb +0 -107
  26. data/spec/controllers/cluster_spec.rb +0 -267
  27. data/spec/controllers/controller_spec.rb +0 -129
  28. data/spec/controllers/service_spec.rb +0 -50
  29. data/spec/daemonizing_spec.rb +0 -200
  30. data/spec/headers_spec.rb +0 -40
  31. data/spec/logging_spec.rb +0 -52
  32. data/spec/perf/request_perf_spec.rb +0 -50
  33. data/spec/perf/response_perf_spec.rb +0 -19
  34. data/spec/perf/server_perf_spec.rb +0 -39
  35. data/spec/rack/loader_spec.rb +0 -42
  36. data/spec/rack/rails_adapter_spec.rb +0 -173
  37. data/spec/rails_app/app/controllers/application.rb +0 -10
  38. data/spec/rails_app/app/controllers/simple_controller.rb +0 -19
  39. data/spec/rails_app/app/helpers/application_helper.rb +0 -3
  40. data/spec/rails_app/app/views/simple/index.html.erb +0 -15
  41. data/spec/rails_app/config/boot.rb +0 -109
  42. data/spec/rails_app/config/environment.rb +0 -64
  43. data/spec/rails_app/config/environments/development.rb +0 -18
  44. data/spec/rails_app/config/environments/production.rb +0 -19
  45. data/spec/rails_app/config/environments/test.rb +0 -22
  46. data/spec/rails_app/config/initializers/inflections.rb +0 -10
  47. data/spec/rails_app/config/initializers/mime_types.rb +0 -5
  48. data/spec/rails_app/config/routes.rb +0 -35
  49. data/spec/rails_app/public/404.html +0 -30
  50. data/spec/rails_app/public/422.html +0 -30
  51. data/spec/rails_app/public/500.html +0 -30
  52. data/spec/rails_app/public/dispatch.cgi +0 -10
  53. data/spec/rails_app/public/dispatch.fcgi +0 -24
  54. data/spec/rails_app/public/dispatch.rb +0 -10
  55. data/spec/rails_app/public/favicon.ico +0 -0
  56. data/spec/rails_app/public/images/rails.png +0 -0
  57. data/spec/rails_app/public/index.html +0 -277
  58. data/spec/rails_app/public/javascripts/application.js +0 -2
  59. data/spec/rails_app/public/javascripts/controls.js +0 -963
  60. data/spec/rails_app/public/javascripts/dragdrop.js +0 -972
  61. data/spec/rails_app/public/javascripts/effects.js +0 -1120
  62. data/spec/rails_app/public/javascripts/prototype.js +0 -4225
  63. data/spec/rails_app/public/robots.txt +0 -5
  64. data/spec/rails_app/script/about +0 -3
  65. data/spec/rails_app/script/console +0 -3
  66. data/spec/rails_app/script/destroy +0 -3
  67. data/spec/rails_app/script/generate +0 -3
  68. data/spec/rails_app/script/performance/benchmarker +0 -3
  69. data/spec/rails_app/script/performance/profiler +0 -3
  70. data/spec/rails_app/script/performance/request +0 -3
  71. data/spec/rails_app/script/plugin +0 -3
  72. data/spec/rails_app/script/process/inspector +0 -3
  73. data/spec/rails_app/script/process/reaper +0 -3
  74. data/spec/rails_app/script/process/spawner +0 -3
  75. data/spec/rails_app/script/runner +0 -3
  76. data/spec/rails_app/script/server +0 -3
  77. data/spec/request/mongrel_spec.rb +0 -39
  78. data/spec/request/parser_spec.rb +0 -254
  79. data/spec/request/persistent_spec.rb +0 -35
  80. data/spec/request/processing_spec.rb +0 -50
  81. data/spec/response_spec.rb +0 -102
  82. data/spec/runner_spec.rb +0 -168
  83. data/spec/server/builder_spec.rb +0 -44
  84. data/spec/server/pipelining_spec.rb +0 -110
  85. data/spec/server/robustness_spec.rb +0 -34
  86. data/spec/server/stopping_spec.rb +0 -55
  87. data/spec/server/swiftiply.yml +0 -6
  88. data/spec/server/swiftiply_spec.rb +0 -32
  89. data/spec/server/tcp_spec.rb +0 -47
  90. data/spec/server/threaded_spec.rb +0 -27
  91. data/spec/server/unix_socket_spec.rb +0 -26
  92. data/spec/server_spec.rb +0 -100
  93. data/spec/spec_helper.rb +0 -234
  94. data/tasks/announce.rake +0 -22
  95. data/tasks/deploy.rake +0 -13
  96. data/tasks/email.erb +0 -27
  97. data/tasks/gem.rake +0 -65
  98. data/tasks/rdoc.rake +0 -25
  99. data/tasks/site.rake +0 -15
  100. data/tasks/spec.rake +0 -43
  101. data/tasks/stats.rake +0 -28
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Request, 'performance' do
4
- it "should be faster then #{max_parsing_time = 0.0002} RubySeconds" do
5
- body = <<-EOS.chomp.gsub("\n", "\r\n")
6
- POST /postit HTTP/1.1
7
- Host: localhost:3000
8
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
9
- Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
10
- Accept-Language: en-us,en;q=0.5
11
- Accept-Encoding: gzip,deflate
12
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
13
- Keep-Alive: 300
14
- Connection: keep-alive
15
- Content-Type: text/html
16
- Content-Length: 37
17
-
18
- hi=there&name=marc&email=macournoyer@gmail.com
19
- EOS
20
-
21
- proc { R(body) }.should be_faster_then(max_parsing_time)
22
- end
23
-
24
- it 'should be comparable to Mongrel parser' do
25
- require 'http11'
26
-
27
- body = <<-EOS.chomp.gsub("\n", "\r\n")
28
- POST /postit HTTP/1.1
29
- Host: localhost:3000
30
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
31
- Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
32
- Accept-Language: en-us,en;q=0.5
33
- Accept-Encoding: gzip,deflate
34
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
35
- Keep-Alive: 300
36
- Connection: keep-alive
37
- Content-Type: text/html
38
- Content-Length: 37
39
-
40
- hi=there&name=marc&email=macournoyer@gmail.com
41
- EOS
42
-
43
- tests = 10_000
44
- puts
45
- Benchmark.bmbm(10) do |results|
46
- results.report("mongrel:") { tests.times { Mongrel::HttpParser.new.execute({}, body.dup, 0) } }
47
- results.report("thin:") { tests.times { Thin::HttpParser.new.execute({'rack.input' => StringIO.new}, body.dup, 0) } }
48
- end
49
- end if ENV['BM']
50
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Response, 'performance' do
4
- before do
5
- @response = Response.new
6
- @response.body = ''
7
- end
8
-
9
- it "should be fast" do
10
- @response.body << <<-EOS
11
- <html><head><title>Dir listing</title></head>
12
- <body><h1>Listing stuff</h1><ul>
13
- #{'<li>Hi!</li>' * 100}
14
- </ul></body></html>
15
- EOS
16
-
17
- proc { @response.each { |l| l } }.should be_faster_then(0.00011)
18
- end
19
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Server, 'performance' do
4
- before do
5
- start_server do |env|
6
- body = env.inspect + env['rack.input'].read
7
- [200, { 'Content-Length' => body.size.to_s }, body]
8
- end
9
- end
10
-
11
- it "should handle GET in less then #{get_request_time = 0.0045} RubySecond" do
12
- proc { get('/') }.should be_faster_then(get_request_time)
13
- end
14
-
15
- it "should handle POST in less then #{post_request_time = 0.007} RubySecond" do
16
- proc { post('/', :file => 'X' * 1000) }.should be_faster_then(post_request_time)
17
- end
18
-
19
- after do
20
- stop_server
21
- end
22
- end
23
-
24
- describe Server, 'UNIX socket performance' do
25
- before do
26
- start_server('/tmp/thin_test.sock') do |env|
27
- body = env.inspect + env['rack.input'].read
28
- [200, { 'Content-Length' => body.size.to_s }, body]
29
- end
30
- end
31
-
32
- it "should handle GET in less then #{get_request_time = 0.002} RubySecond" do
33
- proc { get('/') }.should be_faster_then(get_request_time)
34
- end
35
-
36
- after do
37
- stop_server
38
- end
39
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Rack::Adapter do
4
- before do
5
- @config_ru_path = File.dirname(__FILE__) + '/../../example'
6
- @rails_path = File.dirname(__FILE__) + '/../rails_app'
7
- end
8
-
9
- it "should load Rack app from config" do
10
- Rack::Adapter.load(@config_ru_path + '/config.ru').class.should == Proc
11
- end
12
-
13
- it "should guess Rack app from dir" do
14
- Rack::Adapter.guess(@config_ru_path).should == :rack
15
- end
16
-
17
- it "should guess rails app from dir" do
18
- Rack::Adapter.guess(@rails_path).should == :rails
19
- end
20
-
21
- it "should return nil when can't guess from dir" do
22
- proc { Rack::Adapter.guess('.') }.should raise_error(Rack::AdapterNotFound)
23
- end
24
-
25
- it "should load Rack adapter" do
26
- Rack::Adapter.for(:rack, :chdir => @config_ru_path).class.should == Proc
27
- end
28
-
29
- it "should load Rails adapter" do
30
- Rack::Adapter::Rails.should_receive(:new)
31
- Rack::Adapter.for(:rails, :chdir => @rails_path)
32
- end
33
-
34
- it "should load File adapter" do
35
- Rack::File.should_receive(:new)
36
- Rack::Adapter.for(:file)
37
- end
38
-
39
- it "should raise error when adapter can't be found" do
40
- proc { Rack::Adapter.for(:fart, {}) }.should raise_error(Rack::AdapterNotFound)
41
- end
42
- end
@@ -1,173 +0,0 @@
1
- require 'spec_helper'
2
- require 'rack/mock'
3
-
4
- begin
5
- gem 'rails', '= 2.0.2' # We could freeze Rails in the rails_app dir to remove this
6
-
7
- describe Rack::Adapter::Rails do
8
- before do
9
- @rails_app_path = File.dirname(__FILE__) + '/../rails_app'
10
- @request = Rack::MockRequest.new(Rack::Adapter::Rails.new(:root => @rails_app_path))
11
- end
12
-
13
- it "should handle simple GET request" do
14
- res = @request.get("/simple", :lint => true)
15
-
16
- res.should be_ok
17
- res["Content-Type"].should include("text/html")
18
-
19
- res.body.should include('Simple#index')
20
- end
21
-
22
- it "should handle POST parameters" do
23
- data = "foo=bar"
24
- res = @request.post("/simple/post_form", :input => data, 'CONTENT_LENGTH' => data.size.to_s, :lint => true)
25
-
26
- res.should be_ok
27
- res["Content-Type"].should include("text/html")
28
- res["Content-Length"].should_not be_nil
29
-
30
- res.body.should include('foo: bar')
31
- end
32
-
33
- it "should serve static files" do
34
- res = @request.get("/index.html", :lint => true)
35
-
36
- res.should be_ok
37
- res["Content-Type"].should include("text/html")
38
- end
39
-
40
- it "should serve root with index.html if present" do
41
- res = @request.get("/", :lint => true)
42
-
43
- res.should be_ok
44
- res["Content-Length"].to_i.should == File.size(@rails_app_path + '/public/index.html')
45
- end
46
-
47
- it "should serve page cache if present" do
48
- res = @request.get("/simple/cached?value=cached", :lint => true)
49
-
50
- res.should be_ok
51
- res.body.should == 'cached'
52
-
53
- res = @request.get("/simple/cached?value=notcached")
54
-
55
- res.should be_ok
56
- res.body.should == 'cached'
57
- end
58
-
59
- it "should not serve page cache on POST request" do
60
- res = @request.get("/simple/cached?value=cached", :lint => true)
61
-
62
- res.should be_ok
63
- res.body.should == 'cached'
64
-
65
- res = @request.post("/simple/cached?value=notcached")
66
-
67
- res.should be_ok
68
- res.body.should == 'notcached'
69
- end
70
-
71
- it "handles multiple cookies" do
72
- res = @request.get('/simple/set_cookie?name=a&value=1', :lint => true)
73
-
74
- res.should be_ok
75
- res.original_headers['Set-Cookie'].size.should == 2
76
- res.original_headers['Set-Cookie'].first.should include('a=1; path=/')
77
- res.original_headers['Set-Cookie'].last.should include('_rails_app_session')
78
- end
79
-
80
- after do
81
- FileUtils.rm_rf @rails_app_path + '/public/simple'
82
- end
83
- end
84
-
85
- describe Rack::Adapter::Rails, 'with prefix' do
86
- before do
87
- @rails_app_path = File.dirname(__FILE__) + '/../rails_app'
88
- @prefix = '/nowhere'
89
- @request = Rack::MockRequest.new(
90
- Rack::URLMap.new(
91
- @prefix => Rack::Adapter::Rails.new(:root => @rails_app_path, :prefix => @prefix)))
92
- end
93
-
94
- it "should handle simple GET request" do
95
- res = @request.get("#{@prefix}/simple", :lint => true)
96
-
97
- res.should be_ok
98
- res["Content-Type"].should include("text/html")
99
-
100
- res.body.should include('Simple#index')
101
- end
102
- end
103
-
104
- rescue Gem::LoadError
105
- warn 'Rails 2.0.2 is required to run the Rails adapter specs'
106
- end
107
-
108
- module RailsMock
109
- module VERSION
110
- MAJOR = 0
111
- MINOR = 0
112
- TINY = 0
113
- end
114
- end
115
-
116
- describe Rack::Adapter::Rails, "Adapter version" do
117
- before do
118
- unless defined?(::Rails)
119
- ::Rails = RailsMock
120
- end
121
- end
122
-
123
- it "should use Rack based adapter when Rails = 2.2.3" do
124
- with_rails_version(2, 2, 3) do
125
- Rack::Adapter::Rails.should be_rack_based
126
- end
127
- end
128
-
129
- it "should not use Rack based adapter when Rails < 2.2.3" do
130
- with_rails_version(2, 2, 2) do
131
- Rack::Adapter::Rails.should_not be_rack_based
132
- end
133
- end
134
-
135
- it "should not use Rack based adapter when Rails = 1.2.3" do
136
- with_rails_version(1, 2, 2) do
137
- Rack::Adapter::Rails.should_not be_rack_based
138
- end
139
- end
140
-
141
- it "should use Rack based adapter when Rails = 3.0.0" do
142
- with_rails_version(3, 0, 0) do
143
- Rack::Adapter::Rails.should be_rack_based
144
- end
145
- end
146
-
147
- def with_rails_version(major, minor, tiny)
148
- old_major = ::Rails::VERSION::MAJOR
149
- old_minor = ::Rails::VERSION::MINOR
150
- old_tiny = ::Rails::VERSION::TINY
151
-
152
- silence_warnings do
153
- ::Rails::VERSION.const_set :MAJOR, major
154
- ::Rails::VERSION.const_set :MINOR, minor
155
- ::Rails::VERSION.const_set :TINY, tiny
156
- end
157
-
158
- yield
159
-
160
- silence_warnings do
161
- ::Rails::VERSION.const_set :MAJOR, old_major
162
- ::Rails::VERSION.const_set :MINOR, old_minor
163
- ::Rails::VERSION.const_set :TINY, old_tiny
164
- end
165
- end
166
-
167
- def silence_warnings
168
- old_verbose, $VERBOSE = $VERBOSE, nil
169
- yield
170
- ensure
171
- $VERBOSE = old_verbose
172
- end unless method_defined?(:silence_warnings)
173
- end
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
-
7
- # See ActionController::RequestForgeryProtection for details
8
- # Uncomment the :secret if you're not using the cookie session store
9
- # protect_from_forgery # :secret => 'a8af303b8dabf2d2d8f1a7912ac04d7d'
10
- end
@@ -1,19 +0,0 @@
1
- class SimpleController < ApplicationController
2
- caches_page :cached
3
-
4
- def index
5
- end
6
-
7
- def post_form
8
- render :text => params.to_yaml
9
- end
10
-
11
- def set_cookie
12
- cookies[params[:name]] = params[:value] if params[:name]
13
- render :text => cookies.to_yaml
14
- end
15
-
16
- def cached
17
- render :text => params[:value]
18
- end
19
- end
@@ -1,3 +0,0 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1,15 +0,0 @@
1
- <h1>Simple#index</h1>
2
-
3
- <h2>ENV</h2>
4
- <%= request.env.to_yaml %>
5
-
6
- <h2>Cookies</h2>
7
- <%= request.cookies.to_yaml %>
8
-
9
- <h2>Params</h2>
10
- <%= params.to_yaml %>
11
-
12
- <% form_tag '/simple' do %>
13
- <%= text_field_tag :a %>
14
- <%= submit_tag 'Submit' %>
15
- <% end %>
@@ -1,109 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- # FIXME : Ruby 1.9
28
- def preinitialize
29
- load(preinitializer_path) if File.exists?(preinitializer_path)
30
- end
31
-
32
- def preinitializer_path
33
- "#{RAILS_ROOT}/config/preinitializer.rb"
34
- end
35
- end
36
-
37
- class Boot
38
- def run
39
- load_initializer
40
- Rails::Initializer.run(:set_load_path)
41
- end
42
- end
43
-
44
- class VendorBoot < Boot
45
- def load_initializer
46
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
47
- end
48
- end
49
-
50
- class GemBoot < Boot
51
- def load_initializer
52
- self.class.load_rubygems
53
- load_rails_gem
54
- require 'initializer'
55
- end
56
-
57
- def load_rails_gem
58
- if version = self.class.gem_version
59
- gem 'rails', version
60
- else
61
- gem 'rails'
62
- end
63
- rescue Gem::LoadError => load_error
64
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
- exit 1
66
- end
67
-
68
- class << self
69
- def rubygems_version
70
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
- end
72
-
73
- def gem_version
74
- if defined? RAILS_GEM_VERSION
75
- RAILS_GEM_VERSION
76
- elsif ENV.include?('RAILS_GEM_VERSION')
77
- ENV['RAILS_GEM_VERSION']
78
- else
79
- parse_gem_version(read_environment_rb)
80
- end
81
- end
82
-
83
- def load_rubygems
84
- require 'rubygems'
85
-
86
- unless rubygems_version >= '0.9.4'
87
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
- exit 1
89
- end
90
-
91
- rescue LoadError
92
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
- exit 1
94
- end
95
-
96
- def parse_gem_version(text)
97
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
- end
99
-
100
- private
101
- def read_environment_rb
102
- File.read("#{RAILS_ROOT}/config/environment.rb")
103
- end
104
- end
105
- end
106
- end
107
-
108
- # All that for this:
109
- Rails.boot!