unicorn 2.0.0pre2.4.gf202 → 2.0.0pre3

Sign up to get free protection for your applications and to get access to all the features.
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v2.0.0pre2.GIT
4
+ DEF_VER=v2.0.0pre3.GIT
5
5
 
6
6
  LF='
7
7
  '
data/lib/unicorn/const.rb CHANGED
@@ -7,8 +7,8 @@
7
7
  # improve things much compared to constants.
8
8
  module Unicorn::Const
9
9
 
10
- # The current version of Unicorn, currently 2.0.0pre2
11
- UNICORN_VERSION = "2.0.0pre2"
10
+ # The current version of Unicorn, currently 2.0.0pre3
11
+ UNICORN_VERSION = "2.0.0pre3"
12
12
 
13
13
  # default TCP listen host address (0.0.0.0, all interfaces)
14
14
  DEFAULT_HOST = "0.0.0.0"
@@ -0,0 +1,30 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ module Unicorn
4
+ # This middleware is used to ensure input is buffered to memory
5
+ # or disk (depending on size) before the application is dispatched
6
+ # by entirely consuming it (from TeeInput) beforehand.
7
+ #
8
+ # Usage (in config.ru):
9
+ #
10
+ # require 'unicorn/preread_input'
11
+ # if defined?(Unicorn)
12
+ # use Unicorn::PrereadInput
13
+ # end
14
+ # run YourApp.new
15
+ class PrereadInput
16
+ def initialize(app)
17
+ @app = app
18
+ end
19
+
20
+ def call(env)
21
+ buf = ""
22
+ input = env["rack.input"]
23
+ if buf = input.read(16384)
24
+ true while input.read(16384, buf)
25
+ input.rewind
26
+ end
27
+ @app.call(env)
28
+ end
29
+ end
30
+ end
@@ -17,7 +17,7 @@ opts = {
17
17
  pid = fork do
18
18
  Isolate.now!(opts) do
19
19
  gem 'sqlite3-ruby', '1.2.5'
20
- gem 'kgio', '1.3.0'
20
+ gem 'kgio', '1.3.1'
21
21
  gem 'rack', '1.1.0'
22
22
  end
23
23
  end
@@ -0,0 +1,17 @@
1
+ #\-E none
2
+ require 'digest/sha1'
3
+ require 'unicorn/preread_input'
4
+ use Rack::ContentLength
5
+ use Rack::ContentType, "text/plain"
6
+ use Unicorn::PrereadInput
7
+ nr = 0
8
+ run lambda { |env|
9
+ $stderr.write "app dispatch: #{nr += 1}\n"
10
+ input = env["rack.input"]
11
+ dig = Digest::SHA1.new
12
+ while buf = input.read(16384)
13
+ dig.update(buf)
14
+ end
15
+
16
+ [ 200, {}, [ "#{dig.hexdigest}\n" ] ]
17
+ }
@@ -0,0 +1,48 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 9 "PrereadInput middleware tests"
4
+
5
+ t_begin "setup and start" && {
6
+ random_blob_sha1=$(rsha1 < random_blob)
7
+ unicorn_setup
8
+ unicorn -D -c $unicorn_config preread_input.ru
9
+ unicorn_wait_start
10
+ }
11
+
12
+ t_begin "single identity request" && {
13
+ curl -sSf -T random_blob http://$listen/ > $tmp
14
+ }
15
+
16
+ t_begin "sha1 matches" && {
17
+ test x"$(cat $tmp)" = x"$random_blob_sha1"
18
+ }
19
+
20
+ t_begin "single chunked request" && {
21
+ curl -sSf -T- < random_blob http://$listen/ > $tmp
22
+ }
23
+
24
+ t_begin "sha1 matches" && {
25
+ test x"$(cat $tmp)" = x"$random_blob_sha1"
26
+ }
27
+
28
+ t_begin "app only dispatched twice" && {
29
+ test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )"
30
+ }
31
+
32
+ t_begin "aborted chunked request" && {
33
+ rm -f $tmp
34
+ curl -sSf -T- < $fifo http://$listen/ > $tmp &
35
+ curl_pid=$!
36
+ kill -9 $curl_pid
37
+ wait
38
+ }
39
+
40
+ t_begin "app only dispatched twice" && {
41
+ test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )"
42
+ }
43
+
44
+ t_begin "killing succeeds" && {
45
+ kill -QUIT $unicorn_pid
46
+ }
47
+
48
+ t_done
data/unicorn.gemspec CHANGED
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  # commented out. Nevertheless, upgrading to Rails 2.3.4 or later is
49
49
  # *strongly* recommended for security reasons.
50
50
  s.add_dependency(%q<rack>)
51
- s.add_dependency(%q<kgio>, '~> 1.3.0')
51
+ s.add_dependency(%q<kgio>, '~> 1.3.1')
52
52
 
53
53
  s.add_development_dependency('isolate', '~> 2.1.2')
54
54
 
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1058687251
4
+ hash: -766259860
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0pre2
10
- - 4
11
- - gf202
12
- version: 2.0.0pre2.4.gf202
9
+ - 0pre3
10
+ version: 2.0.0pre3
13
11
  platform: ruby
14
12
  authors:
15
13
  - Unicorn hackers
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-10-08 00:00:00 +00:00
18
+ date: 2010-10-09 00:00:00 +00:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
@@ -42,12 +40,12 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 27
43
+ hash: 25
46
44
  segments:
47
45
  - 1
48
46
  - 3
49
- - 0
50
- version: 1.3.0
47
+ - 1
48
+ version: 1.3.1
51
49
  type: :runtime
52
50
  version_requirements: *id002
53
51
  - !ruby/object:Gem::Dependency
@@ -105,6 +103,7 @@ extra_rdoc_files:
105
103
  - lib/unicorn/http_server.rb
106
104
  - lib/unicorn/launcher.rb
107
105
  - lib/unicorn/oob_gc.rb
106
+ - lib/unicorn/preread_input.rb
108
107
  - lib/unicorn/socket_helper.rb
109
108
  - lib/unicorn/tee_input.rb
110
109
  - lib/unicorn/tmpio.rb
@@ -175,6 +174,7 @@ files:
175
174
  - lib/unicorn/http_server.rb
176
175
  - lib/unicorn/launcher.rb
177
176
  - lib/unicorn/oob_gc.rb
177
+ - lib/unicorn/preread_input.rb
178
178
  - lib/unicorn/socket_helper.rb
179
179
  - lib/unicorn/tee_input.rb
180
180
  - lib/unicorn/tmpio.rb
@@ -195,6 +195,7 @@ files:
195
195
  - t/env.ru
196
196
  - t/my-tap-lib.sh
197
197
  - t/pid.ru
198
+ - t/preread_input.ru
198
199
  - t/rails3-app/.gitignore
199
200
  - t/rails3-app/Gemfile
200
201
  - t/rails3-app/Rakefile
@@ -244,6 +245,7 @@ files:
244
245
  - t/t0302-rails3-alt-working_directory.sh
245
246
  - t/t0303-rails3-alt-working_directory_config.ru.sh
246
247
  - t/t0304-rails3-alt-working_directory_no_embed_cli.sh
248
+ - t/t9000-preread-input.sh
247
249
  - t/test-lib.sh
248
250
  - t/test-rails3.sh
249
251
  - test/aggregate.rb