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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b97ec9f81c0bb5aa55cc42ec96cc349f21c0bb88ebfe907300f58841e8bdcf4a
4
- data.tar.gz: 48c9d21e5d2d4a7fe3d360dde8623deac46c0ddf0efccf94a1543c06e4bf7770
3
+ metadata.gz: 7794469f473ba02c2feb32c638c8659536b5b04b32e1b93479af7638e76e1019
4
+ data.tar.gz: 567e71e0a872ee5a5abcaa00208b149e2b59a69fe3e42f1e73687e3a79a036f9
5
5
  SHA512:
6
- metadata.gz: 9fb4edb4db18989e6a218e15ed81543cf671ca5c925da3e134673fd93832b34c6345c5782b836b8e7f672492a53f73c0c0f83c832c4639beb00da5936f95dcee
7
- data.tar.gz: 4cd296f4c7dd5ae7b72367a1f829589eaab29a3d0bacfff9c973cdfe82f78894c6da96819528421672537f6a308da4e3258290b4afb20b9631b7348a9dbb2379
6
+ metadata.gz: 21ffae9b2a103464dcfc23eae43020df47173c3ff0c8354ec57755dd45607ae56c9b0be14f95291f2b7ae1c2f768b3981553a3a2bee590ec83aa2497f1b2e631
7
+ data.tar.gz: fb203df62bba5e961bcbf380117eaec22c249dd7ed1615e4f6ce59d287ebb4f2901aad30dd8ac0759295882d4b6f9dbdea2e0f594298d9e4972d1e8a6e9a881f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Version 0.11 2025-06-13
2
+
3
+ - Improve logging for protocol errors
4
+ - Enable YJIT when running bin/tp2
5
+
1
6
  # Version 0.10 2025-06-10
2
7
 
3
8
  - Fix static file serving
data/bin/tp2 CHANGED
@@ -90,4 +90,5 @@ end
90
90
 
91
91
  detect_app(opts) if !opts[:app_type]
92
92
 
93
+ RubyVM::YJIT.enable rescue nil
93
94
  TP2.run(opts)
@@ -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 << "0\r\n\r\n" if done
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, "Missing data"
282
+ raise ProtocolError, 'Missing data'
281
283
  end
282
284
 
283
285
  str
data/lib/tp2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TP2
2
- VERSION = '0.10'
2
+ VERSION = '0.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp2
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: '0.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner