puma 8.1.3-java → 8.1.4-java

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: 8baa8f741d980486540e5c05f3efd0f33ba1a4e7fd47dea0637102f8291f75fa
4
- data.tar.gz: 3cdac2c98a753080a75bbc346779a526c412f5d3d81da2042e86f82f8c0757dd
3
+ metadata.gz: 6b5cb76e112171560bbac5970c3f16de31f7dca01b2392648a922ca9c54d2e28
4
+ data.tar.gz: 83efdca73d9f4a64972961b402674d0d8a361bdc59fdb1c6f40f32182d5754fc
5
5
  SHA512:
6
- metadata.gz: 56840da64925f2e469c81d056890078b061c372dde776134b6fbbbcfe90ef689bf24276e9263a5e74b08c8ee2c5a753dcd804da8939a5e6ac5d96b5770e1a348
7
- data.tar.gz: 3ec384ba3fd05b8ef2694fb7c51fbaa06337aa5f20f4dfe0d28c389298fe96f88ddd712a8420802876281d230d2295ce442c581357c10fd3bb9201dde53c627c
6
+ metadata.gz: 703030629428999037a62b6baf2c1129476daaebc3afd00ddb0cc7e1a36544ddd7024f9acba58e20d809fc7f9d204da5b08c85d8702d9335074382c4ba21a487
7
+ data.tar.gz: e5e6475908d2f337d0c59c675a704f67786b4a6bf7e09f1647df605aa5449124276f607285dd1bf3cb1ee55f1e5289da8e99221e0b14890e15886d9e9b34c40b
data/History.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 8.1.4 / 2026-12-01
2
+
3
+ * Bugfixes
4
+ * Return `:wait_readable` instead of raising from `MiniSSL::Socket#read_nonblock` with `exception: false` when the read would block, which broke Action Cable over TLS since 8.0.3 ([#4177])
5
+ * Free MiniSSL engines with Ruby's allocator, fixing heap corruption on mswin ([#4178])
6
+ * Fix a crash when freeing a MiniSSL engine that never got an SSL connection ([#4179])
7
+ * Preserve the SIGTERM exit status when running on JRuby ([#4203])
8
+ * Fix swapped `min` and `max` defaults in `update_thread_pool_min_max` for server plugins ([#4067])
9
+ * Reject a request that has both `Content-Length` and `Transfer-Encoding` with a 400 and close the connection ([#4090], [#4273])
10
+ * Close HTTP/1.0 keep-alive connections when the response body length is unknown ([#4062])
11
+ * Keep the private key out of the `key_pem` error message ([#4061])
12
+ * Validate the CRLF after chunk data when a chunk spans multiple reads ([#4089])
13
+ * Fix `RangeError` for chunk sizes that don't fit in a C `long` ([#4058])
14
+
1
15
  ## 8.1.3 / 2026-11-25
2
16
 
3
17
  * Security
@@ -2455,6 +2469,17 @@ be added back in a future date when a java Puma::MiniSSL is added.
2455
2469
  * Bugfixes
2456
2470
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
2457
2471
 
2472
+ [#4177]:https://github.com/puma/puma/pull/4177 "PR by Nate Berkopec, merged 2026-11-19"
2473
+ [#4178]:https://github.com/puma/puma/pull/4178 "PR by Nate Berkopec, merged 2026-11-19"
2474
+ [#4179]:https://github.com/puma/puma/pull/4179 "PR by Nate Berkopec, merged 2026-11-19"
2475
+ [#4203]:https://github.com/puma/puma/pull/4203 "PR by Nate Berkopec, merged 2026-11-25"
2476
+ [#4067]:https://github.com/puma/puma/pull/4067 "PR by Yuki Nishijima, merged 2026-11-27"
2477
+ [#4090]:https://github.com/puma/puma/pull/4090 "PR by Nate Berkopec, merged 2026-11-30"
2478
+ [#4273]:https://github.com/puma/puma/pull/4273 "PR by Nate Berkopec, merged 2026-11-30"
2479
+ [#4062]:https://github.com/puma/puma/pull/4062 "PR by Samuel Giddins, merged 2026-11-30"
2480
+ [#4061]:https://github.com/puma/puma/pull/4061 "PR by Samuel Giddins, merged 2026-11-30"
2481
+ [#4089]:https://github.com/puma/puma/pull/4089 "PR by Nate Berkopec, merged 2026-11-30"
2482
+ [#4058]:https://github.com/puma/puma/pull/4058 "PR by Wleeaf, merged 2026-11-30"
2458
2483
  [#4135]:https://github.com/puma/puma/pull/4135 "PR by Nate Berkopec, merged 2026-11-15"
2459
2484
  [#4108]:https://github.com/puma/puma/pull/4108 "PR by Nate Berkopec, merged 2026-11-15"
2460
2485
  [#4124]:https://github.com/puma/puma/pull/4124 "PR by Nate Berkopec, merged 2026-11-15"
data/lib/puma/client.rb CHANGED
@@ -538,6 +538,11 @@ module Puma
538
538
 
539
539
  te = @env[TRANSFER_ENCODING2]
540
540
  if te
541
+ if @env.key?(CONTENT_LENGTH)
542
+ @error_status_code = 400
543
+ @env[HTTP_CONNECTION] = CLOSE
544
+ raise HttpParserError, "#{TE_ERR_MSG}, cannot be combined with Content-Length"
545
+ end
541
546
  te_lwr = te.downcase
542
547
  if te.include? ','
543
548
  te_ary = te_lwr.split(',').each { |te| te.gsub!(STRIP_OWS, "") }
@@ -732,10 +737,21 @@ module Puma
732
737
  @chunked_content_length += @body.write(str)
733
738
  end
734
739
 
740
+ def check_chunk_ending(str, left)
741
+ (left - CHUNK_VALID_ENDING_SIZE...left).each do |i|
742
+ next if i < 0 || i >= str.bytesize
743
+
744
+ unless str.getbyte(i) == CHUNK_VALID_ENDING.getbyte(i - left + CHUNK_VALID_ENDING_SIZE)
745
+ raise HttpParserError, "Chunk size mismatch"
746
+ end
747
+ end
748
+ end
749
+
735
750
  def decode_chunk(chunk)
736
751
  return finish_last_chunk(@prev_chunk + chunk) if @in_last_chunk
737
752
 
738
753
  if @partial_part_left > 0
754
+ check_chunk_ending(chunk, @partial_part_left)
739
755
  if @partial_part_left <= chunk.size
740
756
  if @partial_part_left > 2
741
757
  write_chunk(chunk[0..(@partial_part_left-3)]) # skip the \r\n
@@ -800,7 +816,8 @@ module Puma
800
816
 
801
817
  len += 2
802
818
 
803
- part = io.read(len)
819
+ # StringIO#read takes a C long, so don't ask for more than is buffered
820
+ part = io.read([len, io.size].min)
804
821
 
805
822
  unless part
806
823
  @partial_part_left = len
@@ -821,6 +838,7 @@ module Puma
821
838
  write_chunk(part)
822
839
  @partial_part_left = len - part.size
823
840
  when got == len - 1 # edge where we get just \r but not \n
841
+ check_chunk_ending(part, len)
824
842
  write_chunk(part[0..-2])
825
843
  @partial_part_left = len - part.size
826
844
  end
data/lib/puma/const.rb CHANGED
@@ -100,7 +100,7 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "8.1.3"
103
+ PUMA_VERSION = VERSION = "8.1.4"
104
104
  CODE_NAME = "Puma Psychosis"
105
105
 
106
106
  PUMA_SERVER_STRING = ["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
data/lib/puma/launcher.rb CHANGED
@@ -18,6 +18,9 @@ module Puma
18
18
  class Launcher
19
19
  autoload :BundlePruner, 'puma/launcher/bundle_pruner'
20
20
 
21
+ class JRubySigterm < SignalException; end
22
+ private_constant :JRubySigterm
23
+
21
24
  # Returns an instance of Launcher
22
25
  #
23
26
  # +conf+ A Puma::Configuration object indicating how to run the server.
@@ -199,17 +202,18 @@ module Puma
199
202
 
200
203
  # Run the server. This blocks until the server is stopped
201
204
  def run
202
- previous_env = get_env
203
-
204
- @config.plugins.fire_starts self
205
+ return run_server unless Puma.jruby? && Thread.current == Thread.main
205
206
 
206
- setup_signals
207
- set_process_title
208
-
209
- # This blocks until the server is stopped
210
- @runner.run
211
-
212
- do_run_finished(previous_env)
207
+ Thread.handle_interrupt(JRubySigterm => :never) do
208
+ begin
209
+ Thread.handle_interrupt(JRubySigterm => :immediate) { run_server(jruby_sigterm: true) }
210
+ rescue JRubySigterm
211
+ do_graceful_stop
212
+ raise
213
+ end
214
+ end
215
+ rescue JRubySigterm
216
+ raise SignalException, "SIGTERM"
213
217
  end
214
218
 
215
219
  # Return all tcp ports the launcher may be using, TCP or SSL
@@ -253,6 +257,20 @@ module Puma
253
257
 
254
258
  private
255
259
 
260
+ def run_server(jruby_sigterm: false)
261
+ previous_env = get_env
262
+
263
+ @config.plugins.fire_starts self
264
+
265
+ setup_signals(jruby_sigterm)
266
+ set_process_title
267
+
268
+ # This blocks until the server is stopped
269
+ @runner.run
270
+
271
+ do_run_finished(previous_env)
272
+ end
273
+
256
274
  def get_env
257
275
  if defined?(Bundler)
258
276
  env = Bundler::ORIGINAL_ENV.dup
@@ -425,13 +443,13 @@ module Puma
425
443
  end
426
444
  end
427
445
 
428
- def setup_signals
446
+ def setup_signals(jruby_sigterm)
429
447
  unless ENV["PUMA_SKIP_SIGUSR2"]
430
448
  begin
431
449
  Signal.trap "SIGUSR2" do
432
450
  restart
433
451
  end
434
- rescue Exception
452
+ rescue StandardError, NotImplementedError
435
453
  log "*** SIGUSR2 not implemented, signal based restart unavailable!"
436
454
  end
437
455
  end
@@ -441,19 +459,23 @@ module Puma
441
459
  Signal.trap "SIGUSR1" do
442
460
  phased_restart
443
461
  end
444
- rescue Exception
462
+ rescue StandardError, NotImplementedError
445
463
  log "*** SIGUSR1 not implemented, signal based restart unavailable!"
446
464
  end
447
465
  end
448
466
 
449
467
  begin
450
468
  Signal.trap "SIGTERM" do
451
- # Shortcut the control flow in case raise_exception_on_sigterm is true
452
- do_graceful_stop
469
+ if jruby_sigterm && @options[:raise_exception_on_sigterm]
470
+ Thread.main.raise(JRubySigterm, "SIGTERM")
471
+ else
472
+ # Shortcut the control flow in case raise_exception_on_sigterm is true
473
+ do_graceful_stop
453
474
 
454
- raise(SignalException, "SIGTERM") if @options[:raise_exception_on_sigterm]
475
+ raise(SignalException, "SIGTERM") if @options[:raise_exception_on_sigterm]
476
+ end
455
477
  end
456
- rescue Exception
478
+ rescue StandardError, NotImplementedError
457
479
  log "*** SIGTERM not implemented, signal based gracefully stopping unavailable!"
458
480
  end
459
481
 
@@ -461,7 +483,7 @@ module Puma
461
483
  Signal.trap "SIGINT" do
462
484
  stop
463
485
  end
464
- rescue Exception
486
+ rescue StandardError, NotImplementedError
465
487
  log "*** SIGINT not implemented, signal based gracefully stopping unavailable!"
466
488
  end
467
489
 
@@ -473,7 +495,7 @@ module Puma
473
495
  stop
474
496
  end
475
497
  end
476
- rescue Exception
498
+ rescue StandardError, NotImplementedError
477
499
  log "*** SIGHUP not implemented, signal based logs reopening unavailable!"
478
500
  end
479
501
 
@@ -486,7 +508,7 @@ module Puma
486
508
  end
487
509
  end
488
510
  end
489
- rescue Exception
511
+ rescue StandardError, NotImplementedError
490
512
  log "*** SIGINFO/SIGPWR not implemented, signal based backtrace unavailable!"
491
513
  end
492
514
  end
data/lib/puma/minissl.rb CHANGED
@@ -84,13 +84,16 @@ module Puma
84
84
  output
85
85
  end
86
86
 
87
- def read_nonblock(size, *_)
87
+ def read_nonblock(size, *_, exception: true)
88
88
  # *_ is to deal with keyword args that were added
89
89
  # at some point (and being used in the wild)
90
90
  output = engine_read_all
91
91
  return output if output
92
92
 
93
- raise IO::EAGAINWaitReadable unless flush_write_buffer_nonblock
93
+ unless flush_write_buffer_nonblock
94
+ raise IO::EAGAINWaitReadable if exception
95
+ return :wait_readable
96
+ end
94
97
 
95
98
  data = @socket.read_nonblock(size, exception: false)
96
99
  if data == :wait_readable || data == :wait_writable
@@ -103,7 +106,8 @@ module Puma
103
106
  # In the meantime, we can emulate the correct behavior by
104
107
  # capturing :wait_readable & :wait_writable and raising EAGAIN
105
108
  # ourselves.
106
- raise IO::EAGAINWaitReadable
109
+ raise IO::EAGAINWaitReadable if exception
110
+ return :wait_readable
107
111
  elsif data.nil?
108
112
  raise SSLError.exception "HTTP connection?" if bad_tlsv1_3?
109
113
  return nil
@@ -115,7 +119,8 @@ module Puma
115
119
 
116
120
  queue_ciphertext
117
121
  flush_write_buffer_nonblock
118
- raise IO::EAGAINWaitReadable
122
+ raise IO::EAGAINWaitReadable if exception
123
+ :wait_readable
119
124
  end
120
125
 
121
126
  def write_pending?
Binary file
data/lib/puma/response.rb CHANGED
@@ -211,6 +211,15 @@ module Puma
211
211
 
212
212
  cork_socket socket
213
213
 
214
+ http_10_keep_alive = resp_info[:http_10_keep_alive]
215
+ if http_10_keep_alive && !resp_info[:no_body] && !content_length &&
216
+ !resp_info[:transfer_encoding] && !response_hijack
217
+ # a body of unknown length can only be delimited by closing the
218
+ # connection (RFC 9112 §6.3), so it cannot be kept alive
219
+ keep_alive = http_10_keep_alive = false
220
+ end
221
+ io_buffer << CONNECTION_KEEP_ALIVE if http_10_keep_alive
222
+
214
223
  if resp_info[:no_body]
215
224
  # 101 (Switching Protocols) doesn't return here or have content_length,
216
225
  # it should be using `response_hijack`
@@ -542,11 +551,10 @@ module Puma
542
551
  # - HTTP 1.1 assumes the connection will be kept alive if not specified.
543
552
  # Only set the header if we're doing something which is not the default
544
553
  # for this protocol version
545
- if http_11
546
- io_buffer << CONNECTION_CLOSE if !resp_info[:keep_alive]
547
- else
548
- io_buffer << CONNECTION_KEEP_ALIVE if resp_info[:keep_alive]
549
- end
554
+ # HTTP/1.0 keep-alive is written by prepare_response, which knows whether
555
+ # the body can be delimited without closing the connection
556
+ io_buffer << CONNECTION_CLOSE if http_11 && !resp_info[:keep_alive]
557
+ resp_info[:http_10_keep_alive] = !http_11 && resp_info[:keep_alive]
550
558
  resp_info
551
559
  end
552
560
  private :str_headers
@@ -22,10 +22,11 @@ module Puma
22
22
  end
23
23
 
24
24
  # Updates the minimum and maximum number of threads in the thread pool.
25
+ # Omitted arguments default to the corresponding current thread limits.
25
26
  #
26
27
  # @see Puma::Server#update_thread_pool_min_max
27
28
  #
28
- def update_thread_pool_min_max(min: max_threads, max: min_threads)
29
+ def update_thread_pool_min_max(min: min_threads, max: max_threads)
29
30
  @server.update_thread_pool_min_max(min: min, max: max)
30
31
  end
31
32
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.3
4
+ version: 8.1.4
5
5
  platform: java
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-11-24 00:00:00.000000000 Z
10
+ date: 2026-12-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: nio4r