unicorn 3.0.0pre2 → 3.0.0

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=v3.0.0pre2.GIT
4
+ DEF_VER=v3.0.0.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 3.0.0pre2
11
- UNICORN_VERSION = "3.0.0pre2"
10
+ # The current version of Unicorn, currently 3.0.0
11
+ UNICORN_VERSION = "3.0.0"
12
12
 
13
13
  # default TCP listen host address (0.0.0.0, all interfaces)
14
14
  DEFAULT_HOST = "0.0.0.0"
@@ -39,28 +39,25 @@ class Unicorn::StreamInput
39
39
  # ios.read(length [, buffer]) will return immediately if there is
40
40
  # any data and only block when nothing is available (providing
41
41
  # IO#readpartial semantics).
42
- def read(*args)
43
- length = args.shift
44
- rv = args.shift || ''
45
- if length.nil?
46
- read_all(rv)
47
- else
42
+ def read(length = nil, rv = '')
43
+ if length
48
44
  if length <= @rbuf.size
49
- rv.replace(@rbuf.slice(0, length))
50
- @rbuf.replace(@rbuf.slice(length, @rbuf.size) || '')
45
+ length < 0 and raise ArgumentError, "negative length #{length} given"
46
+ rv.replace(@rbuf.slice!(0, length))
51
47
  else
52
- rv.replace(@rbuf)
53
- length -= @rbuf.size
54
- @rbuf.replace('')
55
- until length == 0 || eof? || (rv.size > 0 && @chunked)
56
- @socket.kgio_read(length, @buf) or eof!
48
+ to_read = length - @rbuf.size
49
+ rv.replace(@rbuf.slice!(0, @rbuf.size))
50
+ until to_read == 0 || eof? || (rv.size > 0 && @chunked)
51
+ @socket.kgio_read(to_read, @buf) or eof!
57
52
  filter_body(@rbuf, @buf)
58
53
  rv << @rbuf
59
- length -= @rbuf.size
60
- @rbuf.replace('')
54
+ to_read -= @rbuf.size
61
55
  end
56
+ @rbuf.replace('')
62
57
  end
63
58
  rv = nil if rv.empty? && length != 0
59
+ else
60
+ read_all(rv)
64
61
  end
65
62
  rv
66
63
  end
@@ -83,16 +80,8 @@ class Unicorn::StreamInput
83
80
  re = /\A(.*?#{Regexp.escape(sep)})/
84
81
 
85
82
  begin
86
- @rbuf.gsub!(re, '') and return $1
87
- if eof?
88
- if @rbuf.empty?
89
- return nil
90
- else
91
- rv = @rbuf.dup
92
- @rbuf.replace('')
93
- return rv
94
- end
95
- end
83
+ @rbuf.sub!(re, '') and return $1
84
+ return @rbuf.empty? ? nil : @rbuf.slice!(0, @rbuf.size) if eof?
96
85
  @socket.kgio_read(@@io_chunk_size, @buf) or eof!
97
86
  filter_body(once = '', @buf)
98
87
  @rbuf << once
@@ -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', '2.0.0pre1'
20
+ gem 'kgio', '2.0.0'
21
21
  gem 'rack', '1.1.0'
22
22
  end
23
23
  end
@@ -21,6 +21,13 @@ class TestStreamInput < Test::Unit::TestCase
21
21
  Process.waitall
22
22
  end
23
23
 
24
+ def test_read_negative
25
+ r = init_request('hello')
26
+ si = Unicorn::StreamInput.new(@rd, r)
27
+ assert_raises(ArgumentError) { si.read(-1) }
28
+ assert_equal 'hello', si.read
29
+ end
30
+
24
31
  def test_read_small
25
32
  r = init_request('hello')
26
33
  si = Unicorn::StreamInput.new(@rd, r)
@@ -146,6 +153,43 @@ class TestStreamInput < Test::Unit::TestCase
146
153
  assert_equal '', rv
147
154
  end
148
155
 
156
+ def test_gets_read_mix
157
+ r = init_request("hello\nasdfasdf")
158
+ si = Unicorn::StreamInput.new(@rd, r)
159
+ assert_equal "hello\n", si.gets
160
+ assert_equal "asdfasdf", si.read(9)
161
+ assert_nil si.read(9)
162
+ end
163
+
164
+ def test_gets_read_mix_chunked
165
+ r = @parser = Unicorn::HttpParser.new
166
+ body = "6\r\nhello"
167
+ @buf = "POST / HTTP/1.1\r\n" \
168
+ "Host: localhost\r\n" \
169
+ "Transfer-Encoding: chunked\r\n" \
170
+ "\r\n#{body}"
171
+ assert_equal @env, @parser.headers(@env, @buf)
172
+ assert_equal body, @buf
173
+ si = Unicorn::StreamInput.new(@rd, r)
174
+ @wr.syswrite "\n\r\n"
175
+ assert_equal "hello\n", si.gets
176
+ @wr.syswrite "8\r\nasdfasdf\r\n"
177
+ assert_equal"asdfasdf", si.read(9) + si.read(9)
178
+ @wr.syswrite "0\r\n\r\n"
179
+ assert_nil si.read(9)
180
+ end
181
+
182
+ def test_gets_read_mix_big
183
+ r = init_request("hello\n#{'.' * 65536}")
184
+ si = Unicorn::StreamInput.new(@rd, r)
185
+ assert_equal "hello\n", si.gets
186
+ assert_equal '.' * 16384, si.read(16384)
187
+ assert_equal '.' * 16383, si.read(16383)
188
+ assert_equal '.' * 16384, si.read(16384)
189
+ assert_equal '.' * 16385, si.read(16385)
190
+ assert_nil si.gets
191
+ end
192
+
149
193
  def init_request(body, size = nil)
150
194
  @parser = Unicorn::HttpParser.new
151
195
  body = body.to_s.freeze
@@ -267,6 +267,14 @@ class TestTeeInput < Test::Unit::TestCase
267
267
  assert_equal "World", @env['HTTP_HELLO']
268
268
  end
269
269
 
270
+ def test_gets_read_mix
271
+ r = init_request("hello\nasdfasdf")
272
+ ti = Unicorn::TeeInput.new(@rd, r)
273
+ assert_equal "hello\n", ti.gets
274
+ assert_equal "asdfasdf", ti.read(9)
275
+ assert_nil ti.read(9)
276
+ end
277
+
270
278
  private
271
279
 
272
280
  def init_request(body, size = nil)
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: -766259866
5
- prerelease: true
4
+ hash: 7
5
+ prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 0pre2
10
- version: 3.0.0pre2
9
+ - 0
10
+ version: 3.0.0
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-11-19 00:00:00 +00:00
18
+ date: 2010-11-20 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -375,14 +375,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
375
375
  required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  none: false
377
377
  requirements:
378
- - - ">"
378
+ - - ">="
379
379
  - !ruby/object:Gem::Version
380
- hash: 25
380
+ hash: 3
381
381
  segments:
382
- - 1
383
- - 3
384
- - 1
385
- version: 1.3.1
382
+ - 0
383
+ version: "0"
386
384
  requirements: []
387
385
 
388
386
  rubyforge_project: mongrel