puma 4.0.1-java → 4.1.0-java

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.

@@ -29,8 +29,8 @@ module Puma
29
29
  #
30
30
  def initialize(stdout, stderr)
31
31
  @formatter = DefaultFormatter.new
32
- @stdout = stdout
33
- @stderr = stderr
32
+ @stdout = stdout.dup
33
+ @stderr = stderr.dup
34
34
 
35
35
  @stdout.sync = true
36
36
  @stderr.sync = true
@@ -93,7 +93,10 @@ module Puma
93
93
  # parsing exception.
94
94
  #
95
95
  def parse_error(server, env, error)
96
- @stderr.puts "#{Time.now}: HTTP parse error, malformed request (#{env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR]}): #{error.inspect}\n---\n"
96
+ @stderr.puts "#{Time.now}: HTTP parse error, malformed request " \
97
+ "(#{env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR]}#{env[REQUEST_PATH]}): " \
98
+ "#{error.inspect}" \
99
+ "\n---\n"
97
100
  end
98
101
 
99
102
  # An SSL error has occurred.
@@ -63,6 +63,9 @@ module Puma
63
63
  @options = @config.options
64
64
  @config.clamp
65
65
 
66
+ @events.formatter = Events::PidFormatter.new if clustered?
67
+ @events.formatter = options[:log_formatter] if @options[:log_formatter]
68
+
66
69
  generate_restart_data
67
70
 
68
71
  if clustered? && !Process.respond_to?(:fork)
@@ -81,7 +84,6 @@ module Puma
81
84
  set_rack_environment
82
85
 
83
86
  if clustered?
84
- @events.formatter = Events::PidFormatter.new
85
87
  @options[:logger] = @events
86
88
 
87
89
  @runner = Cluster.new(self, @events)
@@ -54,22 +54,21 @@ module Puma
54
54
  output = engine_read_all
55
55
  return output if output
56
56
 
57
- begin
58
- data = @socket.read_nonblock(size, exception: false)
59
- if data == :wait_readable || data == :wait_writable
60
- if @socket.to_io.respond_to?(data)
61
- @socket.to_io.__send__(data)
62
- elsif data == :wait_readable
63
- IO.select([@socket.to_io])
64
- else
65
- IO.select(nil, [@socket.to_io])
66
- end
67
- elsif !data
68
- return nil
69
- else
70
- break
71
- end
72
- end while true
57
+ data = @socket.read_nonblock(size, exception: false)
58
+ if data == :wait_readable || data == :wait_writable
59
+ # It would make more sense to let @socket.read_nonblock raise
60
+ # EAGAIN if necessary but it seems like it'll misbehave on Windows.
61
+ # I don't have a Windows machine to debug this so I can't explain
62
+ # exactly whats happening in that OS. Please let me know if you
63
+ # find out!
64
+ #
65
+ # In the meantime, we can emulate the correct behavior by
66
+ # capturing :wait_readable & :wait_writable and raising EAGAIN
67
+ # ourselves.
68
+ raise IO::EAGAINWaitReadable
69
+ elsif data.nil?
70
+ return nil
71
+ end
73
72
 
74
73
  @engine.inject(data)
75
74
  output = engine_read_all
@@ -177,10 +176,11 @@ module Puma
177
176
 
178
177
  class Context
179
178
  attr_accessor :verify_mode
180
- attr_reader :no_tlsv1
179
+ attr_reader :no_tlsv1, :no_tlsv1_1
181
180
 
182
181
  def initialize
183
- @no_tlsv1 = false
182
+ @no_tlsv1 = false
183
+ @no_tlsv1_1 = false
184
184
  end
185
185
 
186
186
  if defined?(JRUBY_VERSION)
@@ -220,18 +220,24 @@ module Puma
220
220
  @ca = ca
221
221
  end
222
222
 
223
-
224
223
  def check
225
224
  raise "Key not configured" unless @key
226
225
  raise "Cert not configured" unless @cert
227
226
  end
228
227
  end
229
228
 
229
+ # disables TLSv1
230
230
  def no_tlsv1=(tlsv1)
231
231
  raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1)
232
232
  @no_tlsv1 = tlsv1
233
233
  end
234
234
 
235
+ # disables TLSv1 and TLSv1.1. Overrides `#no_tlsv1=`
236
+ def no_tlsv1_1=(tlsv1_1)
237
+ raise ArgumentError, "Invalid value of no_tlsv1" unless ['true', 'false', true, false].include?(tlsv1_1)
238
+ @no_tlsv1_1 = tlsv1_1
239
+ end
240
+
235
241
  end
236
242
 
237
243
  VERIFY_NONE = 0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puma/plugin'
2
4
 
3
5
  Puma::Plugin.create do
Binary file
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Puma
2
4
  end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Puma::Rack
2
4
  # Rack::URLMap takes a hash mapping urls or paths to apps, and
3
5
  # dispatches accordingly. Support for HTTP/1.1 host names exists if
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/handler/puma'
2
4
 
3
5
  module Rack::Handler
@@ -23,7 +23,7 @@ module Puma
23
23
  # A connection comes into a `Puma::Server` instance, it is then passed to a `Puma::Reactor` instance,
24
24
  # which stores it in an array and waits for any of the connections to be ready for reading.
25
25
  #
26
- # The waiting/wake up is performed with nio4r, which will use the apropriate backend (libev, Java NIO or
26
+ # The waiting/wake up is performed with nio4r, which will use the appropriate backend (libev, Java NIO or
27
27
  # just plain IO#select). The call to `NIO::Selector#select` will "wake up" and
28
28
  # return the references to any objects that caused it to "wake". The reactor
29
29
  # then loops through each of these request objects, and sees if they're complete. If they
@@ -14,6 +14,7 @@ module Puma
14
14
  @options = cli.options
15
15
  @app = nil
16
16
  @control = nil
17
+ @started_at = Time.now
17
18
  end
18
19
 
19
20
  def daemon?
@@ -588,8 +588,11 @@ module Puma
588
588
  end
589
589
 
590
590
  def default_server_port(env)
591
- return PORT_443 if env[HTTPS_KEY] == 'on' || env[HTTPS_KEY] == 'https'
592
- env['HTTP_X_FORWARDED_PROTO'] == 'https' ? PORT_443 : PORT_80
591
+ if ['on', HTTPS].include?(env[HTTPS_KEY]) || env[HTTP_X_FORWARDED_PROTO].to_s[0...5] == HTTPS || env[HTTP_X_FORWARDED_SCHEME] == HTTPS || env[HTTP_X_FORWARDED_SSL] == "on"
592
+ PORT_443
593
+ else
594
+ PORT_80
595
+ end
593
596
  end
594
597
 
595
598
  # Takes the request +req+, invokes the Rack application to construct
@@ -627,23 +630,27 @@ module Puma
627
630
  head = env[REQUEST_METHOD] == HEAD
628
631
 
629
632
  env[RACK_INPUT] = body
630
- env[RACK_URL_SCHEME] = env[HTTPS_KEY] ? HTTPS : HTTP
633
+ env[RACK_URL_SCHEME] = default_server_port(env) == PORT_443 ? HTTPS : HTTP
631
634
 
632
635
  if @early_hints
633
636
  env[EARLY_HINTS] = lambda { |headers|
634
- fast_write client, "HTTP/1.1 103 Early Hints\r\n".freeze
637
+ begin
638
+ fast_write client, "HTTP/1.1 103 Early Hints\r\n".freeze
635
639
 
636
- headers.each_pair do |k, vs|
637
- if vs.respond_to?(:to_s) && !vs.to_s.empty?
638
- vs.to_s.split(NEWLINE).each do |v|
639
- fast_write client, "#{k}: #{v}\r\n"
640
+ headers.each_pair do |k, vs|
641
+ if vs.respond_to?(:to_s) && !vs.to_s.empty?
642
+ vs.to_s.split(NEWLINE).each do |v|
643
+ fast_write client, "#{k}: #{v}\r\n"
644
+ end
645
+ else
646
+ fast_write client, "#{k}: #{vs}\r\n"
640
647
  end
641
- else
642
- fast_write client, "#{k}: #{vs}\r\n"
643
648
  end
644
- end
645
649
 
646
- fast_write client, "\r\n".freeze
650
+ fast_write client, "\r\n".freeze
651
+ rescue ConnectionError
652
+ # noop, if we lost the socket we just won't send the early hints
653
+ end
647
654
  }
648
655
  end
649
656
 
@@ -18,7 +18,7 @@ module Puma
18
18
  r = @server.running || 0
19
19
  t = @server.pool_capacity || 0
20
20
  m = @server.max_threads || 0
21
- %Q!{ "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
21
+ %Q!{ "started_at": "#{@started_at.utc.iso8601}", "backlog": #{b}, "running": #{r}, "pool_capacity": #{t}, "max_threads": #{m} }!
22
22
  end
23
23
 
24
24
  def restart
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/handler'
2
4
 
3
5
  module Rack
@@ -86,7 +88,7 @@ module Rack
86
88
  "Verbose" => "Don't report each request (default: false)"
87
89
  }
88
90
  end
89
- private
91
+
90
92
  def self.set_host_port_to_config(host, port, config)
91
93
  config.clear_binds! if host || port
92
94
 
@@ -398,7 +398,7 @@ case "$1" in
398
398
  ;;
399
399
  remove)
400
400
  if [ "$#" -lt 2 ]; then
401
- echo "Please, specifiy the app's directory to remove."
401
+ echo "Please, specify the app's directory to remove."
402
402
  exit 1
403
403
  else
404
404
  do_remove $2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement