boourns-unicorn 4.4.4 → 4.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/unicorn_http/unicorn_http.rl +3 -1
- data/lib/unicorn/configurator.rb +7 -0
- data/lib/unicorn/http_request.rb +1 -2
- data/lib/unicorn/http_server.rb +1 -2
- data/test/unit/test_configurator.rb +12 -0
- data/unicorn.gemspec +1 -1
- metadata +12 -12
@@ -115,7 +115,7 @@ struct http_parser {
|
|
115
115
|
} len;
|
116
116
|
};
|
117
117
|
|
118
|
-
static ID id_clear, id_set_backtrace;
|
118
|
+
static ID id_clear, id_set_backtrace, id_response_start_sent;
|
119
119
|
|
120
120
|
static void finalize_header(struct http_parser *hp);
|
121
121
|
|
@@ -626,6 +626,7 @@ static VALUE HttpParser_clear(VALUE self)
|
|
626
626
|
|
627
627
|
http_parser_init(hp);
|
628
628
|
rb_funcall(hp->env, id_clear, 0);
|
629
|
+
rb_funcall(self, id_response_start_sent, 1, Qfalse);
|
629
630
|
|
630
631
|
return self;
|
631
632
|
}
|
@@ -1031,6 +1032,7 @@ void Init_unicorn_http(void)
|
|
1031
1032
|
SET_GLOBAL(g_http_connection, "CONNECTION");
|
1032
1033
|
id_clear = rb_intern("clear");
|
1033
1034
|
id_set_backtrace = rb_intern("set_backtrace");
|
1035
|
+
id_response_start_sent = rb_intern("response_start_sent=");
|
1034
1036
|
init_unicorn_httpdate();
|
1035
1037
|
}
|
1036
1038
|
#undef SET_GLOBAL
|
data/lib/unicorn/configurator.rb
CHANGED
@@ -97,6 +97,13 @@ class Unicorn::Configurator
|
|
97
97
|
if ready_pipe = RACKUP.delete(:ready_pipe)
|
98
98
|
server.ready_pipe = ready_pipe
|
99
99
|
end
|
100
|
+
if set[:check_client_connection]
|
101
|
+
set[:listeners].each do |address|
|
102
|
+
if set[:listener_opts][address][:tcp_nopush] == true || set[:listener_opts][address][:tcp_nodelay] == true
|
103
|
+
raise ArgumentError, "With check_client_connection set to true both :tcp_nopush and :tcp_nodelay listener options must be set to false."
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
100
107
|
set.each do |key, value|
|
101
108
|
value == :unset and next
|
102
109
|
skip.include?(key) and next
|
data/lib/unicorn/http_request.rb
CHANGED
@@ -41,6 +41,7 @@ class Unicorn::HttpParser
|
|
41
41
|
|
42
42
|
def self.check_client_connection
|
43
43
|
@@check_client_connection
|
44
|
+
true
|
44
45
|
end
|
45
46
|
|
46
47
|
def self.check_client_connection=(bool)
|
@@ -87,8 +88,6 @@ class Unicorn::HttpParser
|
|
87
88
|
if @@check_client_connection && headers?
|
88
89
|
@response_start_sent = true
|
89
90
|
Unicorn::Const::HTTP_RESPONSE_START.each { |c| socket.write(c) }
|
90
|
-
else
|
91
|
-
@response_start_sent = false
|
92
91
|
end
|
93
92
|
|
94
93
|
e[RACK_INPUT] = 0 == content_length ?
|
data/lib/unicorn/http_server.rb
CHANGED
@@ -533,7 +533,7 @@ class Unicorn::HttpServer
|
|
533
533
|
Unicorn.log_error(@logger, "app error", e)
|
534
534
|
Unicorn::Const::ERROR_500_RESPONSE
|
535
535
|
end
|
536
|
-
msg =
|
536
|
+
msg = "HTTP/1.1 #{msg}" unless @request.response_start_sent
|
537
537
|
client.kgio_trywrite(msg)
|
538
538
|
client.close
|
539
539
|
rescue
|
@@ -550,7 +550,6 @@ class Unicorn::HttpServer
|
|
550
550
|
# once a client is accepted, it is processed in its entirety here
|
551
551
|
# in 3 easy steps: read request, call app, write app response
|
552
552
|
def process_client(client)
|
553
|
-
@request.response_start_sent = false
|
554
553
|
status, headers, body = @app.call(env = @request.read(client))
|
555
554
|
|
556
555
|
if 100 == status.to_i
|
@@ -151,6 +151,18 @@ class TestConfigurator < Test::Unit::TestCase
|
|
151
151
|
assert test_struct.check_client_connection
|
152
152
|
end
|
153
153
|
|
154
|
+
def test_check_client_connection_with_tcp_bad
|
155
|
+
tmp = Tempfile.new('unicorn_config')
|
156
|
+
test_struct = TestStruct.new
|
157
|
+
listener = "127.0.0.1:12345"
|
158
|
+
tmp.syswrite("check_client_connection true\n")
|
159
|
+
tmp.syswrite("listen '#{listener}', :tcp_nopush => true\n")
|
160
|
+
|
161
|
+
assert_raises(ArgumentError) do
|
162
|
+
Unicorn::Configurator.new(:config_file => tmp.path).commit!(test_struct)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
154
166
|
def test_after_fork_proc
|
155
167
|
test_struct = TestStruct.new
|
156
168
|
[ proc { |a,b| }, Proc.new { |a,b| }, lambda { |a,b| } ].each do |my_proc|
|
data/unicorn.gemspec
CHANGED
metadata
CHANGED
@@ -3,7 +3,7 @@ name: !binary |-
|
|
3
3
|
Ym9vdXJucy11bmljb3Ju
|
4
4
|
version: !ruby/object:Gem::Version
|
5
5
|
version: !binary |-
|
6
|
-
|
6
|
+
NC40LjU=
|
7
7
|
prerelease:
|
8
8
|
platform: ruby
|
9
9
|
authors:
|
@@ -11,12 +11,12 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-11-
|
14
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: !binary |-
|
18
18
|
cmFjaw==
|
19
|
-
requirement: &
|
19
|
+
requirement: &70303153240700 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,11 +24,11 @@ dependencies:
|
|
24
24
|
version: '0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70303153240700
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: !binary |-
|
30
30
|
a2dpbw==
|
31
|
-
requirement: &
|
31
|
+
requirement: &70303153236920 !ruby/object:Gem::Requirement
|
32
32
|
none: false
|
33
33
|
requirements:
|
34
34
|
- - !binary |-
|
@@ -38,11 +38,11 @@ dependencies:
|
|
38
38
|
Mi42
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
|
-
version_requirements: *
|
41
|
+
version_requirements: *70303153236920
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: !binary |-
|
44
44
|
cmFpbmRyb3Bz
|
45
|
-
requirement: &
|
45
|
+
requirement: &70303153236380 !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
47
|
requirements:
|
48
48
|
- - !binary |-
|
@@ -52,11 +52,11 @@ dependencies:
|
|
52
52
|
MC43
|
53
53
|
type: :runtime
|
54
54
|
prerelease: false
|
55
|
-
version_requirements: *
|
55
|
+
version_requirements: *70303153236380
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: !binary |-
|
58
58
|
aXNvbGF0ZQ==
|
59
|
-
requirement: &
|
59
|
+
requirement: &70303153235560 !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|
62
62
|
- - !binary |-
|
@@ -66,11 +66,11 @@ dependencies:
|
|
66
66
|
My4y
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70303153235560
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: !binary |-
|
72
72
|
d3Jvbmdkb2M=
|
73
|
-
requirement: &
|
73
|
+
requirement: &70303153234260 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - !binary |-
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
MS42LjE=
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
|
-
version_requirements: *
|
83
|
+
version_requirements: *70303153234260
|
84
84
|
description: ! '\Unicorn is an HTTP server for Rack applications designed to only
|
85
85
|
serve
|
86
86
|
|