unicorn 1.1.5 → 1.1.6

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=v1.1.5.GIT
4
+ DEF_VER=v1.1.6.GIT
5
5
 
6
6
  LF='
7
7
  '
data/lib/unicorn.rb CHANGED
@@ -646,6 +646,7 @@ module Unicorn
646
646
  response = app.call(env)
647
647
  end
648
648
  HttpResponse.write(client, response, HttpRequest::PARSER.headers?)
649
+ client.close # flushes and uncorks the socket immediately, no keepalive
649
650
  rescue => e
650
651
  handle_error(client, e)
651
652
  end
data/lib/unicorn/const.rb CHANGED
@@ -8,8 +8,8 @@ module Unicorn
8
8
  # Symbols did not really improve things much compared to constants.
9
9
  module Const
10
10
 
11
- # The current version of Unicorn, currently 1.1.5
12
- UNICORN_VERSION="1.1.5"
11
+ # The current version of Unicorn, currently 1.1.6
12
+ UNICORN_VERSION="1.1.6"
13
13
 
14
14
  DEFAULT_HOST = "0.0.0.0" # default TCP listen host address
15
15
  DEFAULT_PORT = 8080 # default TCP listen port
@@ -63,7 +63,6 @@ module Unicorn::HttpResponse
63
63
  end
64
64
 
65
65
  body.each { |chunk| socket.write(chunk) }
66
- socket.close # flushes and uncorks the socket immediately
67
66
  ensure
68
67
  body.respond_to?(:close) and body.close
69
68
  end
@@ -0,0 +1,23 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 4 "write-on-close tests for funky response-bodies"
4
+
5
+ t_begin "setup and start" && {
6
+ unicorn_setup
7
+ unicorn -D -c $unicorn_config write-on-close.ru
8
+ unicorn_wait_start
9
+ }
10
+
11
+ t_begin "write-on-close response body succeeds" && {
12
+ test xGoodbye = x"$(curl -sSf http://$listen/)"
13
+ }
14
+
15
+ t_begin "killing succeeds" && {
16
+ kill $unicorn_pid
17
+ }
18
+
19
+ t_begin "check stderr" && {
20
+ check_stderr
21
+ }
22
+
23
+ t_done
@@ -0,0 +1,11 @@
1
+ class WriteOnClose
2
+ def each(&block)
3
+ @callback = block
4
+ end
5
+
6
+ def close
7
+ @callback.call "7\r\nGoodbye\r\n0\r\n\r\n"
8
+ end
9
+ end
10
+ use Rack::ContentType, "text/plain"
11
+ run(lambda { |_| [ 200, [%w(Transfer-Encoding chunked)], WriteOnClose.new ] })
@@ -15,15 +15,14 @@ class ResponseTest < Test::Unit::TestCase
15
15
  def test_response_headers
16
16
  out = StringIO.new
17
17
  HttpResponse.write(out,[200, {"X-Whatever" => "stuff"}, ["cool"]])
18
- assert out.closed?
19
-
18
+ assert ! out.closed?
20
19
  assert out.length > 0, "output didn't have data"
21
20
  end
22
21
 
23
22
  def test_response_string_status
24
23
  out = StringIO.new
25
24
  HttpResponse.write(out,['200', {}, []])
26
- assert out.closed?
25
+ assert ! out.closed?
27
26
  assert out.length > 0, "output didn't have data"
28
27
  assert_equal 1, out.string.split(/\r\n/).grep(/^Status: 200 OK/).size
29
28
  end
@@ -33,7 +32,7 @@ class ResponseTest < Test::Unit::TestCase
33
32
  $, = "\f\v"
34
33
  out = StringIO.new
35
34
  HttpResponse.write(out,[200, {"X-k" => "cd","X-y" => "z"}, ["cool"]])
36
- assert out.closed?
35
+ assert ! out.closed?
37
36
  resp = out.string
38
37
  assert ! resp.include?("\f\v"), "output didn't use $, ($OFS)"
39
38
  ensure
@@ -43,7 +42,7 @@ class ResponseTest < Test::Unit::TestCase
43
42
  def test_response_200
44
43
  io = StringIO.new
45
44
  HttpResponse.write(io, [200, {}, []])
46
- assert io.closed?
45
+ assert ! io.closed?
47
46
  assert io.length > 0, "output didn't have data"
48
47
  end
49
48
 
@@ -51,7 +50,7 @@ class ResponseTest < Test::Unit::TestCase
51
50
  code = 400
52
51
  io = StringIO.new
53
52
  HttpResponse.write(io, [code, {}, []])
54
- assert io.closed?
53
+ assert ! io.closed?
55
54
  lines = io.string.split(/\r\n/)
56
55
  assert_match(/.* Bad Request$/, lines.first,
57
56
  "wrong default reason phrase")
@@ -60,7 +59,7 @@ class ResponseTest < Test::Unit::TestCase
60
59
  def test_rack_multivalue_headers
61
60
  out = StringIO.new
62
61
  HttpResponse.write(out,[200, {"X-Whatever" => "stuff\nbleh"}, []])
63
- assert out.closed?
62
+ assert ! out.closed?
64
63
  assert_match(/^X-Whatever: stuff\r\nX-Whatever: bleh\r\n/, out.string)
65
64
  end
66
65
 
@@ -69,7 +68,7 @@ class ResponseTest < Test::Unit::TestCase
69
68
  def test_status_header_added
70
69
  out = StringIO.new
71
70
  HttpResponse.write(out,[200, {"X-Whatever" => "stuff"}, []])
72
- assert out.closed?
71
+ assert ! out.closed?
73
72
  assert_equal 1, out.string.split(/\r\n/).grep(/^Status: 200 OK/i).size
74
73
  end
75
74
 
@@ -80,7 +79,7 @@ class ResponseTest < Test::Unit::TestCase
80
79
  out = StringIO.new
81
80
  header_hash = {"X-Whatever" => "stuff", 'StaTus' => "666" }
82
81
  HttpResponse.write(out,[200, header_hash, []])
83
- assert out.closed?
82
+ assert ! out.closed?
84
83
  assert_equal 1, out.string.split(/\r\n/).grep(/^Status: 200 OK/i).size
85
84
  assert_equal 1, out.string.split(/\r\n/).grep(/^Status:/i).size
86
85
  end
@@ -91,7 +90,7 @@ class ResponseTest < Test::Unit::TestCase
91
90
  body.rewind
92
91
  out = StringIO.new
93
92
  HttpResponse.write(out,[200, {}, body])
94
- assert out.closed?
93
+ assert ! out.closed?
95
94
  assert body.closed?
96
95
  assert_match(expect_body, out.string.split(/\r\n/).last)
97
96
  end
@@ -99,7 +98,7 @@ class ResponseTest < Test::Unit::TestCase
99
98
  def test_unknown_status_pass_through
100
99
  out = StringIO.new
101
100
  HttpResponse.write(out,["666 I AM THE BEAST", {}, [] ])
102
- assert out.closed?
101
+ assert ! out.closed?
103
102
  headers = out.string.split(/\r\n\r\n/).first.split(/\r\n/)
104
103
  assert %r{\AHTTP/\d\.\d 666 I AM THE BEAST\z}.match(headers[0])
105
104
  status = headers.grep(/\AStatus:/i).first
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 5
10
- version: 1.1.5
9
+ - 6
10
+ version: 1.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Unicorn hackers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-27 00:00:00 +00:00
18
+ date: 2011-01-07 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -214,6 +214,7 @@ files:
214
214
  - t/t0009-winch_ttin.sh
215
215
  - t/t0011-active-unix-socket.sh
216
216
  - t/t0012-reload-empty-config.sh
217
+ - t/t0018-write-on-close.sh
217
218
  - t/t0300-rails3-basic.sh
218
219
  - t/t0301-rails3-missing-config-ru.sh
219
220
  - t/t0302-rails3-alt-working_directory.sh
@@ -221,6 +222,7 @@ files:
221
222
  - t/t0304-rails3-alt-working_directory_no_embed_cli.sh
222
223
  - t/test-lib.sh
223
224
  - t/test-rails3.sh
225
+ - t/write-on-close.ru
224
226
  - test/aggregate.rb
225
227
  - test/benchmark/README
226
228
  - test/benchmark/dd.ru