unicorn 3.0.0pre1 → 3.0.0pre1.9.g86d2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/unicorn/http_server.rb +1 -1
- data/lib/unicorn/stream_input.rb +1 -1
- data/t/t0002-parser-error.sh +31 -0
- data/t/t0013.ru +12 -0
- data/t/t0014.ru +12 -0
- data/test/unit/test_stream_input.rb +17 -0
- metadata +8 -3
data/lib/unicorn/http_server.rb
CHANGED
@@ -500,7 +500,7 @@ class Unicorn::HttpServer
|
|
500
500
|
msg = case e
|
501
501
|
when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::EINVAL,Errno::EBADF
|
502
502
|
Unicorn::Const::ERROR_500_RESPONSE
|
503
|
-
when HttpParserError # try to tell the client they're bad
|
503
|
+
when Unicorn::HttpParserError # try to tell the client they're bad
|
504
504
|
Unicorn::Const::ERROR_400_RESPONSE
|
505
505
|
else
|
506
506
|
logger.error "Read error: #{e.inspect}"
|
data/lib/unicorn/stream_input.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 5 "parser error test"
|
4
|
+
|
5
|
+
t_begin "setup and startup" && {
|
6
|
+
unicorn_setup
|
7
|
+
unicorn -D env.ru -c $unicorn_config
|
8
|
+
unicorn_wait_start
|
9
|
+
}
|
10
|
+
|
11
|
+
t_begin "send a bad request" && {
|
12
|
+
(
|
13
|
+
printf 'GET / HTTP/1/1\r\nHost: example.com\r\n\r\n'
|
14
|
+
cat $fifo > $tmp &
|
15
|
+
wait
|
16
|
+
echo ok > $ok
|
17
|
+
) | socat - TCP:$listen > $fifo
|
18
|
+
test xok = x$(cat $ok)
|
19
|
+
}
|
20
|
+
|
21
|
+
dbgcat tmp
|
22
|
+
|
23
|
+
t_begin "response should be a 400" && {
|
24
|
+
grep -F 'HTTP/1.1 400 Bad Request' $tmp
|
25
|
+
}
|
26
|
+
|
27
|
+
t_begin "server stderr should be clean" && check_stderr
|
28
|
+
|
29
|
+
t_begin "term signal sent" && kill $unicorn_pid
|
30
|
+
|
31
|
+
t_done
|
data/t/t0013.ru
ADDED
data/t/t0014.ru
ADDED
@@ -129,6 +129,23 @@ class TestStreamInput < Test::Unit::TestCase
|
|
129
129
|
assert_equal '', buf
|
130
130
|
end
|
131
131
|
|
132
|
+
def test_read_zero
|
133
|
+
r = init_request('hello')
|
134
|
+
si = Unicorn::StreamInput.new(@rd, r)
|
135
|
+
assert_equal '', si.read(0)
|
136
|
+
buf = 'asdf'
|
137
|
+
rv = si.read(0, buf)
|
138
|
+
assert_equal rv.object_id, buf.object_id
|
139
|
+
assert_equal '', buf
|
140
|
+
assert_equal 'hello', si.read
|
141
|
+
assert_nil si.read(5)
|
142
|
+
assert_equal '', si.read(0)
|
143
|
+
buf = 'hello'
|
144
|
+
rv = si.read(0, buf)
|
145
|
+
assert_equal rv.object_id, buf.object_id
|
146
|
+
assert_equal '', rv
|
147
|
+
end
|
148
|
+
|
132
149
|
def init_request(body, size = nil)
|
133
150
|
@parser = Unicorn::HttpParser.new
|
134
151
|
body = body.to_s.freeze
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -5096542530
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0pre1
|
10
|
-
|
10
|
+
- 9
|
11
|
+
- g86d2
|
12
|
+
version: 3.0.0pre1.9.g86d2
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Unicorn hackers
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2010-11-17 00:00:00 +
|
20
|
+
date: 2010-11-17 00:00:00 +08:00
|
19
21
|
default_executable:
|
20
22
|
dependencies:
|
21
23
|
- !ruby/object:Gem::Dependency
|
@@ -232,6 +234,7 @@ files:
|
|
232
234
|
- t/t0000-http-basic.sh
|
233
235
|
- t/t0001-reload-bad-config.sh
|
234
236
|
- t/t0002-config-conflict.sh
|
237
|
+
- t/t0002-parser-error.sh
|
235
238
|
- t/t0003-working_directory.sh
|
236
239
|
- t/t0004-working_directory_broken.sh
|
237
240
|
- t/t0005-working_directory_app.rb.sh
|
@@ -244,7 +247,9 @@ files:
|
|
244
247
|
- t/t0011-active-unix-socket.sh
|
245
248
|
- t/t0012-reload-empty-config.sh
|
246
249
|
- t/t0013-rewindable-input-false.sh
|
250
|
+
- t/t0013.ru
|
247
251
|
- t/t0014-rewindable-input-true.sh
|
252
|
+
- t/t0014.ru
|
248
253
|
- t/t0300-rails3-basic.sh
|
249
254
|
- t/t0301-rails3-missing-config-ru.sh
|
250
255
|
- t/t0302-rails3-alt-working_directory.sh
|