tp2 0.10 → 0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/bin/tp2 +1 -0
- data/lib/tp2/http1_adapter.rb +7 -5
- data/lib/tp2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7794469f473ba02c2feb32c638c8659536b5b04b32e1b93479af7638e76e1019
|
4
|
+
data.tar.gz: 567e71e0a872ee5a5abcaa00208b149e2b59a69fe3e42f1e73687e3a79a036f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ffae9b2a103464dcfc23eae43020df47173c3ff0c8354ec57755dd45607ae56c9b0be14f95291f2b7ae1c2f768b3981553a3a2bee590ec83aa2497f1b2e631
|
7
|
+
data.tar.gz: fb203df62bba5e961bcbf380117eaec22c249dd7ed1615e4f6ce59d287ebb4f2901aad30dd8ac0759295882d4b6f9dbdea2e0f594298d9e4972d1e8a6e9a881f
|
data/CHANGELOG.md
CHANGED
data/bin/tp2
CHANGED
data/lib/tp2/http1_adapter.rb
CHANGED
@@ -32,6 +32,8 @@ module TP2
|
|
32
32
|
# we're done
|
33
33
|
when SystemCallError
|
34
34
|
@opts[:log]&.log("Encountered #{e.class}, closing connection")
|
35
|
+
when ProtocolError
|
36
|
+
@opts[:log]&.log("Protocol error (#{e.message}), closing connection")
|
35
37
|
when StandardError
|
36
38
|
@opts[:log]&.log("Unhandled exception #{e.class}: #{e.message}, closing connection")
|
37
39
|
@opts[:log]&.log(e.backtrace.join("\n"))
|
@@ -128,6 +130,9 @@ module TP2
|
|
128
130
|
@response_headers = headers
|
129
131
|
end
|
130
132
|
|
133
|
+
EMPTY_CHUNK = "0\r\n\r\n"
|
134
|
+
EMPTY_CHUNK_LEN = EMPTY_CHUNK.bytesize
|
135
|
+
|
131
136
|
# Sends a response body chunk. If no headers were sent, default headers are
|
132
137
|
# sent using #send_headers. if the done option is true(thy), an empty chunk
|
133
138
|
# will be sent to signal response completion to the client.
|
@@ -138,7 +143,7 @@ module TP2
|
|
138
143
|
def send_chunk(request, chunk, done: false)
|
139
144
|
data = +''
|
140
145
|
data << "#{chunk.bytesize.to_s(16)}\r\n#{chunk}\r\n" if chunk
|
141
|
-
data <<
|
146
|
+
data << EMPTY_CHUNK if done
|
142
147
|
return if data.empty?
|
143
148
|
|
144
149
|
request.tx_incr(data.bytesize)
|
@@ -149,9 +154,6 @@ module TP2
|
|
149
154
|
end
|
150
155
|
end
|
151
156
|
|
152
|
-
EMPTY_CHUNK = "0\r\n\r\n"
|
153
|
-
EMPTY_CHUNK_LEN = EMPTY_CHUNK.bytesize
|
154
|
-
|
155
157
|
# Finishes the response to the current request. If no headers were sent,
|
156
158
|
# default headers are sent using #send_headers.
|
157
159
|
# @return [void]
|
@@ -277,7 +279,7 @@ module TP2
|
|
277
279
|
def read(len, buf = nil, raise_on_eof = true)
|
278
280
|
str = @stream.get_string(buf, len)
|
279
281
|
if !str && raise_on_eof
|
280
|
-
raise ProtocolError,
|
282
|
+
raise ProtocolError, 'Missing data'
|
281
283
|
end
|
282
284
|
|
283
285
|
str
|
data/lib/tp2/version.rb
CHANGED