puma 5.6.0 → 5.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b26655d47e2cc0987b78174ca6f6f7f9e16cfc584d1925cee08b2c4fd8d8a63e
4
- data.tar.gz: 48aaec83462461d40fba5791679f8a81a677ea11731337d05213f358e1e1df01
3
+ metadata.gz: 469723b0faecde36baaac342696d0b59d73086f199a020e89d18ae33e2b181f0
4
+ data.tar.gz: cf2f9bb437d6bf29c6ad1fe5a166ed4db0c9c0c0d67a239d7f07e62b8d993a6b
5
5
  SHA512:
6
- metadata.gz: e09ac76431f64ef08f5be4da5d2792e6ff7a152235534cc3c9a9798bf2bb34041fc98d6050b489598b1a9625bb9af13af355e3d4c9689cc055ab2790adbbcc8e
7
- data.tar.gz: a2609c1568543ce1b41f51eff668e59ccacc79582c447fed74aeb334403e8f9212bb19f676ee2cd949f5209d240ab735495a5d364e549c4ab24676f1941801d5
6
+ metadata.gz: b677ffb75bd299a97fc19eefa2caf8f3a80b8db0600d980ea4700fcb1fd12fd7c4079182e38bc4fc43879e668bffdc757247f4024dfd7e0d13ceb29181debbc4
7
+ data.tar.gz: cd06e3f7cbecffafb7aec87831a24055f45f5e6313d8808ab797116efa9e410e01539382499465f3c23bb957aace762ba24a9deb8ecfdc1c4bf1f0cff852688d
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 5.6.1 / 2022-01-26
2
+
3
+ * Bugfixes
4
+ * Reverted a commit which appeared to be causing occasional blank header values ([#2809])
5
+
1
6
  ## 5.6.0 / 2022-01-25
2
7
 
3
8
  * Features
@@ -1830,6 +1835,7 @@ be added back in a future date when a java Puma::MiniSSL is added.
1830
1835
  * Bugfixes
1831
1836
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
1832
1837
 
1838
+ [#2809]:https://github.com/puma/puma/pull/2809 "PR by @dentarg, merged 2022-01-26"
1833
1839
  [#2764]:https://github.com/puma/puma/pull/2764 "PR by @dentarg, merged 2022-01-18"
1834
1840
  [#2708]:https://github.com/puma/puma/issues/2708 "Issue by @erikaxel, closed 2022-01-18"
1835
1841
  [#2780]:https://github.com/puma/puma/pull/2780 "PR by @dalibor, merged 2022-01-01"
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 = "5.6.0".freeze
103
+ PUMA_VERSION = VERSION = "5.6.1".freeze
104
104
  CODE_NAME = "Birdie's Version".freeze
105
105
 
106
106
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
data/lib/puma/request.rb CHANGED
@@ -46,7 +46,11 @@ module Puma
46
46
  env[HIJACK_P] = true
47
47
  env[HIJACK] = client
48
48
 
49
- env[RACK_INPUT] = client.body
49
+ body = client.body
50
+
51
+ head = env[REQUEST_METHOD] == HEAD
52
+
53
+ env[RACK_INPUT] = body
50
54
  env[RACK_URL_SCHEME] ||= default_server_port(env) == PORT_443 ? HTTPS : HTTP
51
55
 
52
56
  if @early_hints
@@ -65,58 +69,36 @@ module Puma
65
69
  # A rack extension. If the app writes #call'ables to this
66
70
  # array, we will invoke them when the request is done.
67
71
  #
68
- env[RACK_AFTER_REPLY] = []
72
+ after_reply = env[RACK_AFTER_REPLY] = []
69
73
 
70
74
  begin
71
- status, headers, res_body = @thread_pool.with_force_shutdown do
72
- @app.call(env)
73
- end
74
-
75
- return :async if client.hijacked
76
-
77
- status = status.to_i
78
-
79
- if status == -1
80
- unless headers.empty? and res_body == []
81
- raise "async response must have empty headers and body"
75
+ begin
76
+ status, headers, res_body = @thread_pool.with_force_shutdown do
77
+ @app.call(env)
82
78
  end
83
79
 
84
- return :async
85
- end
86
- rescue ThreadPool::ForceShutdown => e
87
- @events.unknown_error e, client, "Rack app"
88
- @events.log "Detected force shutdown of a thread"
89
-
90
- status, headers, res_body = lowlevel_error(e, env, 503)
91
- rescue Exception => e
92
- @events.unknown_error e, client, "Rack app"
80
+ return :async if client.hijacked
93
81
 
94
- status, headers, res_body = lowlevel_error(e, env, 500)
95
- end
82
+ status = status.to_i
96
83
 
97
- write_response(status, headers, res_body, lines, requests, client)
98
- end
84
+ if status == -1
85
+ unless headers.empty? and res_body == []
86
+ raise "async response must have empty headers and body"
87
+ end
99
88
 
100
- # Does the actual response writing for Request#handle_request and Server#client_error
101
- #
102
- # @param status [Integer] the status returned by the Rack application
103
- # @param headers [Hash] the headers returned by the Rack application
104
- # @param res_body [Array] the body returned by the Rack application
105
- # @param lines [Puma::IOBuffer] modified in place
106
- # @param requests [Integer] number of inline requests handled
107
- # @param client [Puma::Client]
108
- # @return [Boolean,:async]
109
- def write_response(status, headers, res_body, lines, requests, client)
110
- env = client.env
111
- io = client.io
89
+ return :async
90
+ end
91
+ rescue ThreadPool::ForceShutdown => e
92
+ @events.unknown_error e, client, "Rack app"
93
+ @events.log "Detected force shutdown of a thread"
112
94
 
113
- return false if closed_socket?(io)
114
- lines.clear
95
+ status, headers, res_body = lowlevel_error(e, env, 503)
96
+ rescue Exception => e
97
+ @events.unknown_error e, client, "Rack app"
115
98
 
116
- head = env[REQUEST_METHOD] == HEAD
117
- after_reply = env[RACK_AFTER_REPLY] || []
99
+ status, headers, res_body = lowlevel_error(e, env, 500)
100
+ end
118
101
 
119
- begin
120
102
  res_info = {}
121
103
  res_info[:content_length] = nil
122
104
  res_info[:no_body] = head
@@ -167,9 +149,9 @@ module Puma
167
149
  res_body.each do |part|
168
150
  next if part.bytesize.zero?
169
151
  if chunked
170
- fast_write io, (part.bytesize.to_s(16) << line_ending)
171
- fast_write io, part # part may have different encoding
172
- fast_write io, line_ending
152
+ fast_write io, (part.bytesize.to_s(16) << line_ending)
153
+ fast_write io, part # part may have different encoding
154
+ fast_write io, line_ending
173
155
  else
174
156
  fast_write io, part
175
157
  end
@@ -187,7 +169,7 @@ module Puma
187
169
  ensure
188
170
  uncork_socket io
189
171
 
190
- client.body.close if client.body
172
+ body.close
191
173
  client.tempfile.unlink if client.tempfile
192
174
  res_body.close if res_body.respond_to? :close
193
175
 
data/lib/puma/server.rb CHANGED
@@ -476,7 +476,7 @@ module Puma
476
476
  end
477
477
  true
478
478
  rescue StandardError => e
479
- client_error(e, client, buffer, requests)
479
+ client_error(e, client)
480
480
  # The ensure tries to close +client+ down
481
481
  requests > 0
482
482
  ensure
@@ -504,36 +504,34 @@ module Puma
504
504
  # :nocov:
505
505
 
506
506
  # Handle various error types thrown by Client I/O operations.
507
- def client_error(e, client, buffer = ::Puma::IOBuffer.new, requests = 1)
507
+ def client_error(e, client)
508
508
  # Swallow, do not log
509
509
  return if [ConnectionError, EOFError].include?(e.class)
510
510
 
511
+ lowlevel_error(e, client.env)
511
512
  case e
512
513
  when MiniSSL::SSLError
513
514
  @events.ssl_error e, client.io
514
515
  when HttpParserError
515
- status, headers, res_body = lowlevel_error(e, client.env, 400)
516
- write_response(status, headers, res_body, buffer, requests, client)
516
+ client.write_error(400)
517
517
  @events.parse_error e, client
518
518
  else
519
- status, headers, res_body = lowlevel_error(e, client.env)
520
- write_response(status, headers, res_body, buffer, requests, client)
519
+ client.write_error(500)
521
520
  @events.unknown_error e, nil, "Read"
522
521
  end
523
522
  end
524
523
 
525
524
  # A fallback rack response if +@app+ raises as exception.
526
525
  #
527
- def lowlevel_error(e, env, status = 500)
526
+ def lowlevel_error(e, env, status=500)
528
527
  if handler = @options[:lowlevel_error_handler]
529
528
  if handler.arity == 1
530
- handler_status, headers, res_body = handler.call(e)
529
+ return handler.call(e)
531
530
  elsif handler.arity == 2
532
- handler_status, headers, res_body = handler.call(e, env)
531
+ return handler.call(e, env)
533
532
  else
534
- handler_status, headers, res_body = handler.call(e, env, status)
533
+ return handler.call(e, env, status)
535
534
  end
536
- return [handler_status || status, headers || {}, res_body || []]
537
535
  end
538
536
 
539
537
  if @leak_stack_on_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix