unicorn-simon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unicorn/http_request.rb +31 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fabe2ee1dc0ca2d385eacce6b3e06b85d028ab78
|
4
|
+
data.tar.gz: 5c3a0278f09b24227219afba7d5ecd1d478639ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f966aa43e2c30d2e0ccfa3932708e7fa63f5279dfa66fbcd4dbadc81d3f4851b7474a2074c9604bd84f85ff801657e0354fc11c9b586ebc4cdd09b7a8c93dd46
|
7
|
+
data.tar.gz: 16eb0a564dd6acd3e1b452f18a1e3e141789069348cf19a4ce18f9b6ad95c5514bf1f64572601cc90ad58fb2ca94e156efa1850c849ebdf48018f3d69b1b8196
|
data/lib/unicorn/http_request.rb
CHANGED
@@ -29,9 +29,9 @@ class Unicorn::HttpParser
|
|
29
29
|
# 2.2+ optimizes hash assignments when used with literal string keys
|
30
30
|
HTTP_RESPONSE_START = [ 'HTTP', '/1.1 ']
|
31
31
|
@@input_class = Unicorn::TeeInput
|
32
|
+
@@raindrops_tcp_info_defined = defined?(Raindrops::TCP_Info)
|
32
33
|
@@check_client_connection = false
|
33
34
|
|
34
|
-
# TCP_TIME_WAIT: 6, TCP_CLOSE: 7, TCP_CLOSE_WAIT: 8, TCP_LAST_ACK: 9
|
35
35
|
IGNORED_CHECK_CLIENT_SOCKET_STATES = (6..9)
|
36
36
|
|
37
37
|
def self.input_class
|
@@ -87,18 +87,7 @@ def read(socket)
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# detect if the socket is valid by checking client connection.
|
90
|
-
if @@check_client_connection
|
91
|
-
if defined?(Raindrops::TCP_Info)
|
92
|
-
tcp_info = Raindrops::TCP_Info.new(socket)
|
93
|
-
if IGNORED_CHECK_CLIENT_SOCKET_STATES.cover?(tcp_info.state)
|
94
|
-
socket.close
|
95
|
-
raise Errno::EPIPE
|
96
|
-
end
|
97
|
-
elsif headers?
|
98
|
-
self.response_start_sent = true
|
99
|
-
HTTP_RESPONSE_START.each { |c| socket.write(c) }
|
100
|
-
end
|
101
|
-
end
|
90
|
+
check_client_connection(socket) if @@check_client_connection
|
102
91
|
|
103
92
|
e['rack.input'] = 0 == content_length ?
|
104
93
|
NULL_IO : @@input_class.new(socket, self)
|
@@ -119,4 +108,33 @@ def call
|
|
119
108
|
def hijacked?
|
120
109
|
env.include?('rack.hijack_io'.freeze)
|
121
110
|
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def check_client_connection(socket)
|
115
|
+
if @@raindrops_tcp_info_defined && TCPSocket === socket
|
116
|
+
tcp_info = Raindrops::TCP_Info.new(socket)
|
117
|
+
raise Errno::EPIPE, "client closed connection".freeze, [] if closed_state?(tcp_info.state)
|
118
|
+
elsif headers?
|
119
|
+
self.response_start_sent = true
|
120
|
+
HTTP_RESPONSE_START.each { |c| socket.write(c) }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def closed_state?(state)
|
125
|
+
case state
|
126
|
+
when 6 # TCP_TIME_WAIT
|
127
|
+
true
|
128
|
+
when 7 # TCP_CLOSE
|
129
|
+
true
|
130
|
+
when 8 # TCP_CLOSE_WAIT
|
131
|
+
true
|
132
|
+
when 9 # TCP_LAST_ACK
|
133
|
+
true
|
134
|
+
when 11 # TCP_CLOSING
|
135
|
+
true
|
136
|
+
else
|
137
|
+
false
|
138
|
+
end
|
139
|
+
end
|
122
140
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn-simon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unicorn hackers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|