puma 6.0.0 → 6.2.0

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: c8a1a6014d9e1130e8ba06d5f74d472216448df3dbce4c15c4c24c91fbfe5e30
4
- data.tar.gz: f1be3485e37cd230f6c35854aeb959ffeab1dac0162bf482799a4755222bc498
3
+ metadata.gz: 677c15b54efd114ff1e95b31d37efc806c3fdbc955988a2d33a37c4b4b10007f
4
+ data.tar.gz: fb375bd8be23a5945b5fa497b124444905a5364815e725636eaad86c7d42c5e2
5
5
  SHA512:
6
- metadata.gz: bbdd201a97e5dffccbbb8d8f336693746b87763313422a94ac21f73641ca712b9d2461051cc0bd02771b51af606ce595c2dd09bff0c716146cf9ac56e7ae51f4
7
- data.tar.gz: e378848b22d1139559edd6736a9164a5cd98064c6232f0b2cc108122f79c93429ec33b156baa17e6ff82e9b3c77dbddbd22b2a0525a16f749129cf6f70c006da
6
+ metadata.gz: 81fbd7fc8da45a1cf3a7dd7c233ae97a1cf41fb788a263ed14f4ce12c0ceac9c024d209f0a99ce61ed9a29e409e7c1442a266b43a89d87f7fb9537e3e6c3526a
7
+ data.tar.gz: 21651a742ad2ec25804b435b44c2cf3d7bca6f691a36d405f413a2b0f325216f45df5f983ada1b3b5367cf35306fae4d8de46613b657ea5c27a2097d74ba72fd
data/History.md CHANGED
@@ -1,4 +1,54 @@
1
- ## 6.0.0 / 2022-10-XX
1
+ ## 6.2.0 / 2023-03-29
2
+
3
+ * Features
4
+ * Ability to supply a custom logger ([#2770], [#2511])
5
+ * Warn when clustered-only hooks are defined in single mode ([#3089])
6
+ * Adds the on_booted event ([#2709])
7
+
8
+ * Bugfixes
9
+ * Loggers - internal_write - catch Errno::EINVAL ([#3091])
10
+ * commonlogger.rb - fix HIJACK time format, use constants, not strings ([#3074])
11
+ * Fixed some edge cases regarding request hijacking ([#3072])
12
+
13
+
14
+ ## 6.1.1 / 2023-02-28
15
+
16
+ * Bugfixes
17
+ * We no longer try to use the systemd plugin for JRuby ([#3079])
18
+ * Allow ::Rack::Handler::Puma.run to work regardless of whether Rack/Rackup are loaded ([#3080])
19
+
20
+ ## 6.1.0 / 2023-02-12
21
+
22
+ * Features
23
+ * WebSocket support via partial hijack ([#3058], [#3007])
24
+ * Add built-in systemd notify support ([#3011])
25
+ * Periodically send status to systemd ([#3006], [#2604])
26
+ * Introduce the ability to return 413: payload too large for requests ([#3040])
27
+ * Log loaded extensions when `PUMA_DEBUG` is set ([#3036], [#3020])
28
+
29
+ * Bugfixes
30
+ * Fix issue with rack 3 compatibility re: rackup ([#3061], [#3057])
31
+ * Allow setting TCP low_latency with SSL listener ([#3065])
32
+
33
+ * Performance
34
+ * Reduce memory usage for large file uploads ([#3062])
35
+
36
+ ## 6.0.2 / 2023-01-01
37
+
38
+ * Refactor
39
+ * Remove use of etc and time gems in Puma ([#3035], [#3033])
40
+ * Refactor const.rb - freeze ([#3016])
41
+
42
+ ## 6.0.1 / 2022-12-20
43
+
44
+ * Bugfixes
45
+ * Handle waking up a closed selector in Reactor#add ([#3005])
46
+ * Fixup response processing, enumerable bodies ([#3004], [#3000])
47
+ * Correctly close app body for all code paths ([#3002], [#2999])
48
+ * Refactor
49
+ * Add IOBuffer to Client, remove from ThreadPool thread instances ([#3013])
50
+
51
+ ## 6.0.0 / 2022-10-14
2
52
 
3
53
  * Breaking Changes
4
54
  * Dropping Ruby 2.2 and 2.3 support (now 2.4+) ([#2919])
@@ -9,6 +59,9 @@
9
59
  * Prefix all environment variables with `PUMA_` ([#2924], [#2853])
10
60
  * Removed some constants ([#2957], [#2958], [#2959], [#2960])
11
61
  * The following classes are now part of Puma's private API: `Client`, `Cluster::Worker`, `Cluster::Worker`, `HandleRequest`. ([#2988])
62
+ * Configuration constants like `DefaultRackup` removed ([#2928])
63
+ * Extracted `LogWriter` from `Events` ([#2798])
64
+ * Only accept the standard 8 HTTP methods, others rejected with 501. ([#2932])
12
65
 
13
66
  * Features
14
67
  * Increase throughput on large (100kb+) response bodies by 3-10x ([#2896], [#2892])
@@ -34,7 +87,6 @@
34
87
 
35
88
  * Refactor
36
89
  * log_writer.rb - add internal_write method ([#2888])
37
- * [WIP] Refactor: Split out LogWriter from Events (no logic change) ([#2798])
38
90
  * Extract prune_bundler code into it's own class. ([#2797])
39
91
  * Refactor Launcher#run to increase readability (no logic change) ([#2795])
40
92
  * Ruby 3.2 will have native IO#wait_* methods, don't require io/wait ([#2903])
@@ -1915,6 +1967,36 @@ be added back in a future date when a java Puma::MiniSSL is added.
1915
1967
  * Bugfixes
1916
1968
  * Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
1917
1969
 
1970
+ [#2770]:https://github.com/puma/puma/pull/2770 "PR by @vzajkov, merged 2023-03-29"
1971
+ [#2511]:https://github.com/puma/puma/issues/2511 "Issue by @jchristie55332, closed 2021-12-12"
1972
+ [#3089]:https://github.com/puma/puma/pull/3089 "PR by @Vuta, merged 2023-03-06"
1973
+ [#2709]:https://github.com/puma/puma/pull/2709 "PR by @rodzyn, merged 2023-02-20"
1974
+ [#3091]:https://github.com/puma/puma/pull/3091 "PR by @MSP-Greg, merged 2023-03-28"
1975
+ [#3074]:https://github.com/puma/puma/pull/3074 "PR by @MSP-Greg, merged 2023-03-14"
1976
+ [#3072]:https://github.com/puma/puma/pull/3072 "PR by @MSP-Greg, merged 2023-02-17"
1977
+ [#3079]:https://github.com/puma/puma/pull/3079 "PR by @mohamedhafez, merged 2023-02-24"
1978
+ [#3080]:https://github.com/puma/puma/pull/3080 "PR by @MSP-Greg, merged 2023-02-16"
1979
+ [#3058]:https://github.com/puma/puma/pull/3058 "PR by @dentarg, merged 2023-01-29"
1980
+ [#3007]:https://github.com/puma/puma/issues/3007 "Issue by @MSP-Greg, closed 2023-01-29"
1981
+ [#3011]:https://github.com/puma/puma/pull/3011 "PR by @joaomarcos96, merged 2023-01-03"
1982
+ [#3006]:https://github.com/puma/puma/pull/3006 "PR by @QWYNG, merged 2023-02-09"
1983
+ [#2604]:https://github.com/puma/puma/issues/2604 "Issue by @dgoetz, closed 2023-02-09"
1984
+ [#3040]:https://github.com/puma/puma/pull/3040 "PR by @shayonj, merged 2023-01-02"
1985
+ [#3036]:https://github.com/puma/puma/pull/3036 "PR by @MSP-Greg, merged 2023-01-13"
1986
+ [#3020]:https://github.com/puma/puma/issues/3020 "Issue by @dentarg, closed 2023-01-13"
1987
+ [#3061]:https://github.com/puma/puma/pull/3061 "PR by @MSP-Greg, merged 2023-02-12"
1988
+ [#3057]:https://github.com/puma/puma/issues/3057 "Issue by @mmarvb8h, closed 2023-02-12"
1989
+ [#3065]:https://github.com/puma/puma/pull/3065 "PR by @MSP-Greg, merged 2023-02-11"
1990
+ [#3062]:https://github.com/puma/puma/pull/3062 "PR by @willkoehler, merged 2023-01-29"
1991
+ [#3035]:https://github.com/puma/puma/pull/3035 "PR by @MSP-Greg, merged 2022-12-24"
1992
+ [#3033]:https://github.com/puma/puma/issues/3033 "Issue by @jules-w2, closed 2022-12-24"
1993
+ [#3016]:https://github.com/puma/puma/pull/3016 "PR by @MSP-Greg, merged 2022-12-24"
1994
+ [#3005]:https://github.com/puma/puma/pull/3005 "PR by @JuanitoFatas, merged 2022-11-04"
1995
+ [#3004]:https://github.com/puma/puma/pull/3004 "PR by @MSP-Greg, merged 2022-11-24"
1996
+ [#3000]:https://github.com/puma/puma/issues/3000 "Issue by @dentarg, closed 2022-11-24"
1997
+ [#3002]:https://github.com/puma/puma/pull/3002 "PR by @MSP-Greg, merged 2022-11-03"
1998
+ [#2999]:https://github.com/puma/puma/issues/2999 "Issue by @aymeric-ledorze, closed 2022-11-03"
1999
+ [#3013]:https://github.com/puma/puma/pull/3013 "PR by @MSP-Greg, merged 2022-11-13"
1918
2000
  [#2919]:https://github.com/puma/puma/pull/2919 "PR by @MSP-Greg, merged 2022-08-30"
1919
2001
  [#2652]:https://github.com/puma/puma/issues/2652 "Issue by @Roguelazer, closed 2022-09-04"
1920
2002
  [#2653]:https://github.com/puma/puma/pull/2653 "PR by @Roguelazer, closed 2022-03-07"
@@ -1928,7 +2010,10 @@ be added back in a future date when a java Puma::MiniSSL is added.
1928
2010
  [#2958]:https://github.com/puma/puma/pull/2958 "PR by @JuanitoFatas, merged 2022-09-16"
1929
2011
  [#2959]:https://github.com/puma/puma/pull/2959 "PR by @JuanitoFatas, merged 2022-09-16"
1930
2012
  [#2960]:https://github.com/puma/puma/pull/2960 "PR by @JuanitoFatas, merged 2022-09-16"
1931
- [#2988]:https://github.com/puma/puma/issues/2988 "Issue by @MSP-Greg, merged 2022-10-12"
2013
+ [#2988]:https://github.com/puma/puma/pull/2988 "PR by @MSP-Greg, merged 2022-10-12"
2014
+ [#2928]:https://github.com/puma/puma/pull/2928 "PR by @nateberkopec, merged 2022-09-10"
2015
+ [#2798]:https://github.com/puma/puma/pull/2798 "PR by @johnnyshields, merged 2022-02-05"
2016
+ [#2932]:https://github.com/puma/puma/pull/2932 "PR by @mrzasa, merged 2022-09-12"
1932
2017
  [#2896]:https://github.com/puma/puma/pull/2896 "PR by @MSP-Greg, merged 2022-09-13"
1933
2018
  [#2892]:https://github.com/puma/puma/pull/2892 "PR by @guilleiguaran, closed 2022-09-13"
1934
2019
  [#2923]:https://github.com/puma/puma/pull/2923 "PR by @nateberkopec, merged 2022-09-09"
@@ -1949,11 +2034,9 @@ be added back in a future date when a java Puma::MiniSSL is added.
1949
2034
  [#2904]:https://github.com/puma/puma/pull/2904 "PR by @kares, merged 2022-08-27"
1950
2035
  [#2884]:https://github.com/puma/puma/pull/2884 "PR by @kares, merged 2022-05-30"
1951
2036
  [#2897]:https://github.com/puma/puma/pull/2897 "PR by @Edouard-chin, merged 2022-08-27"
1952
- [#2932]:https://github.com/puma/puma/pull/2932 "PR by @mrzasa, merged 2022-09-12"
1953
2037
  [#1441]:https://github.com/puma/puma/issues/1441 "Issue by @nirvdrum, closed 2022-09-12"
1954
2038
  [#2956]:https://github.com/puma/puma/pull/2956 "PR by @MSP-Greg, merged 2022-09-15"
1955
2039
  [#2888]:https://github.com/puma/puma/pull/2888 "PR by @MSP-Greg, merged 2022-06-01"
1956
- [#2798]:https://github.com/puma/puma/pull/2798 "PR by @johnnyshields, merged 2022-02-05"
1957
2040
  [#2797]:https://github.com/puma/puma/pull/2797 "PR by @johnnyshields, merged 2022-02-01"
1958
2041
  [#2795]:https://github.com/puma/puma/pull/2795 "PR by @johnnyshields, merged 2022-01-31"
1959
2042
  [#2903]:https://github.com/puma/puma/pull/2903 "PR by @MSP-Greg, merged 2022-08-27"
data/README.md CHANGED
@@ -157,6 +157,15 @@ before_fork do
157
157
  end
158
158
  ```
159
159
 
160
+ You can also specify a block to be run after puma is booted using `on_booted`:
161
+
162
+ ```ruby
163
+ # config/puma.rb
164
+ on_booted do
165
+ # configuration here
166
+ end
167
+ ```
168
+
160
169
  ### Error handling
161
170
 
162
171
  If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
@@ -345,11 +354,13 @@ end
345
354
 
346
355
  ## Deployment
347
356
 
348
- Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
357
+ * Puma has support for Capistrano with an [external gem](https://github.com/seuros/capistrano-puma).
358
+
359
+ * Additionally, Puma has support for built-in daemonization via the [puma-daemon](https://github.com/kigster/puma-daemon) ruby gem. The gem restores the `daemonize` option that was removed from Puma starting version 5, but only for MRI Ruby.
360
+
349
361
 
350
362
  It is common to use process monitors with Puma. Modern process monitors like systemd or rc.d
351
- provide continuous monitoring and restarts for increased
352
- reliability in production environments:
363
+ provide continuous monitoring and restarts for increased reliability in production environments:
353
364
 
354
365
  * [rc.d](docs/jungle/rc.d/README.md)
355
366
  * [systemd](docs/systemd.md)
@@ -365,6 +376,7 @@ Community guides:
365
376
  * [puma-metrics](https://github.com/harmjanblok/puma-metrics) — export Puma metrics to Prometheus
366
377
  * [puma-plugin-statsd](https://github.com/yob/puma-plugin-statsd) — send Puma metrics to statsd
367
378
  * [puma-plugin-systemd](https://github.com/sj26/puma-plugin-systemd) — deeper integration with systemd for notify, status and watchdog
379
+ * [puma-plugin-telemetry](https://github.com/babbel/puma-plugin-telemetry) - telemetry plugin for Puma offering various targets to publish
368
380
 
369
381
  ### Monitoring
370
382
 
data/docs/nginx.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is a very common setup using an upstream. It was adapted from some Capistrano recipe I found on the Internet a while ago.
4
4
 
5
- ```
5
+ ```nginx
6
6
  upstream myapp {
7
7
  server unix:///myapp/tmp/puma.sock;
8
8
  }
data/docs/systemd.md CHANGED
@@ -24,8 +24,7 @@ After=network.target
24
24
 
25
25
  [Service]
26
26
  # Puma supports systemd's `Type=notify` and watchdog service
27
- # monitoring, if the [sd_notify](https://github.com/agis/ruby-sdnotify) gem is installed,
28
- # as of Puma 5.1 or later.
27
+ # monitoring, as of Puma 5.1 or later.
29
28
  # On earlier versions of Puma or JRuby, change this to `Type=simple` and remove
30
29
  # the `WatchdogSec` line.
31
30
  Type=notify
data/lib/puma/binder.rb CHANGED
@@ -158,10 +158,10 @@ module Puma
158
158
  ios_len = @ios.length
159
159
  params = Util.parse_query uri.query
160
160
 
161
- opt = params.key?('low_latency') && params['low_latency'] != 'false'
161
+ low_latency = params.key?('low_latency') && params['low_latency'] != 'false'
162
162
  backlog = params.fetch('backlog', 1024).to_i
163
163
 
164
- io = add_tcp_listener uri.host, uri.port, opt, backlog
164
+ io = add_tcp_listener uri.host, uri.port, low_latency, backlog
165
165
 
166
166
  @ios[ios_len..-1].each do |i|
167
167
  addr = loc_addr_str i
@@ -251,7 +251,8 @@ module Puma
251
251
  else
252
252
  ios_len = @ios.length
253
253
  backlog = params.fetch('backlog', 1024).to_i
254
- io = add_ssl_listener uri.host, uri.port, ctx, optimize_for_latency = true, backlog
254
+ low_latency = params['low_latency'] != 'false'
255
+ io = add_ssl_listener uri.host, uri.port, ctx, low_latency, backlog
255
256
 
256
257
  @ios[ios_len..-1].each do |i|
257
258
  addr = loc_addr_str i
data/lib/puma/cli.rb CHANGED
@@ -93,7 +93,7 @@ module Puma
93
93
  #
94
94
 
95
95
  def setup_options
96
- @conf = Configuration.new do |user_config, file_config|
96
+ @conf = Configuration.new({}, {events: @events}) do |user_config, file_config|
97
97
  @parser = OptionParser.new do |o|
98
98
  o.on "-b", "--bind URI", "URI to bind to (tcp://, unix://, ssl://)" do |arg|
99
99
  user_config.bind arg
data/lib/puma/client.rb CHANGED
@@ -9,6 +9,7 @@ class IO
9
9
  end
10
10
 
11
11
  require_relative 'detect'
12
+ require_relative 'io_buffer'
12
13
  require 'tempfile'
13
14
  require 'forwardable'
14
15
 
@@ -65,6 +66,7 @@ module Puma
65
66
  def initialize(io, env=nil)
66
67
  @io = io
67
68
  @to_io = io.to_io
69
+ @io_buffer = IOBuffer.new
68
70
  @proto_env = env
69
71
  @env = env ? env.dup : nil
70
72
 
@@ -84,6 +86,9 @@ module Puma
84
86
  @requests_served = 0
85
87
  @hijacked = false
86
88
 
89
+ @http_content_length_limit = nil
90
+ @http_content_length_limit_exceeded = false
91
+
87
92
  @peerip = nil
88
93
  @peer_family = nil
89
94
  @listener = nil
@@ -93,12 +98,14 @@ module Puma
93
98
  @body_remain = 0
94
99
 
95
100
  @in_last_chunk = false
101
+
102
+ @read_buffer = +""
96
103
  end
97
104
 
98
105
  attr_reader :env, :to_io, :body, :io, :timeout_at, :ready, :hijacked,
99
- :tempfile
106
+ :tempfile, :io_buffer, :http_content_length_limit_exceeded
100
107
 
101
- attr_writer :peerip
108
+ attr_writer :peerip, :http_content_length_limit
102
109
 
103
110
  attr_accessor :remote_addr_header, :listener
104
111
 
@@ -138,6 +145,7 @@ module Puma
138
145
 
139
146
  def reset(fast_check=true)
140
147
  @parser.reset
148
+ @io_buffer.reset
141
149
  @read_header = true
142
150
  @read_proxy = !!@expect_proxy_proto
143
151
  @env = @proto_env.dup
@@ -148,6 +156,7 @@ module Puma
148
156
  @body_remain = 0
149
157
  @peerip = nil if @remote_addr_header
150
158
  @in_last_chunk = false
159
+ @http_content_length_limit_exceeded = false
151
160
 
152
161
  if @buffer
153
162
  return false unless try_to_parse_proxy_protocol
@@ -207,6 +216,17 @@ module Puma
207
216
  end
208
217
 
209
218
  def try_to_finish
219
+ if env[CONTENT_LENGTH] && above_http_content_limit(env[CONTENT_LENGTH].to_i)
220
+ @http_content_length_limit_exceeded = true
221
+ end
222
+
223
+ if @http_content_length_limit_exceeded
224
+ @buffer = nil
225
+ @body = EmptyBody
226
+ set_ready
227
+ return true
228
+ end
229
+
210
230
  return read_body if in_data_phase
211
231
 
212
232
  begin
@@ -236,6 +256,10 @@ module Puma
236
256
 
237
257
  @parsed_bytes = @parser.execute(@env, @buffer, @parsed_bytes)
238
258
 
259
+ if @parser.finished? && above_http_content_limit(@parser.body.bytesize)
260
+ @http_content_length_limit_exceeded = true
261
+ end
262
+
239
263
  if @parser.finished?
240
264
  return setup_body
241
265
  elsif @parsed_bytes >= MAX_HEADER
@@ -411,7 +435,7 @@ module Puma
411
435
  end
412
436
 
413
437
  begin
414
- chunk = @io.read_nonblock(want)
438
+ chunk = @io.read_nonblock(want, @read_buffer)
415
439
  rescue IO::WaitReadable
416
440
  return false
417
441
  rescue SystemCallError, IOError
@@ -443,7 +467,7 @@ module Puma
443
467
  def read_chunked_body
444
468
  while true
445
469
  begin
446
- chunk = @io.read_nonblock(4096)
470
+ chunk = @io.read_nonblock(4096, @read_buffer)
447
471
  rescue IO::WaitReadable
448
472
  return false
449
473
  rescue SystemCallError, IOError
@@ -591,5 +615,9 @@ module Puma
591
615
  @requests_served += 1
592
616
  @ready = true
593
617
  end
618
+
619
+ def above_http_content_limit(value)
620
+ @http_content_length_limit&.< value
621
+ end
594
622
  end
595
623
  end
@@ -115,6 +115,11 @@ module Puma
115
115
 
116
116
  while restart_server.pop
117
117
  server_thread = server.run
118
+
119
+ if @log_writer.debug? && index == 0
120
+ debug_loaded_extensions "Loaded Extensions - worker 0:"
121
+ end
122
+
118
123
  stat_thread ||= Thread.new(@worker_write) do |io|
119
124
  Puma.set_thread_name "stat pld"
120
125
  base_payload = "p#{Process.pid}"
data/lib/puma/cluster.rb CHANGED
@@ -6,8 +6,6 @@ require_relative 'plugin'
6
6
  require_relative 'cluster/worker_handle'
7
7
  require_relative 'cluster/worker'
8
8
 
9
- require 'time'
10
-
11
9
  module Puma
12
10
  # This class is instantiated by the `Puma::Launcher` and used
13
11
  # to boot and serve a Ruby application when puma "workers" are needed
@@ -252,18 +250,18 @@ module Puma
252
250
  old_worker_count = @workers.count { |w| w.phase != @phase }
253
251
  worker_status = @workers.map do |w|
254
252
  {
255
- started_at: w.started_at.utc.iso8601,
253
+ started_at: utc_iso8601(w.started_at),
256
254
  pid: w.pid,
257
255
  index: w.index,
258
256
  phase: w.phase,
259
257
  booted: w.booted?,
260
- last_checkin: w.last_checkin.utc.iso8601,
258
+ last_checkin: utc_iso8601(w.last_checkin),
261
259
  last_status: w.last_status,
262
260
  }
263
261
  end
264
262
 
265
263
  {
266
- started_at: @started_at.utc.iso8601,
264
+ started_at: utc_iso8601(@started_at),
267
265
  workers: @workers.size,
268
266
  phase: @phase,
269
267
  booted_workers: worker_status.count { |w| w[:booted] },
@@ -469,6 +467,7 @@ module Puma
469
467
  @events.fire(:ping!, w)
470
468
  if !booted && @workers.none? {|worker| worker.last_status.empty?}
471
469
  @events.fire_on_booted!
470
+ debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
472
471
  booted = true
473
472
  end
474
473
  end
@@ -478,6 +477,7 @@ module Puma
478
477
  end
479
478
  if in_phased_restart && workers_not_booted.zero?
480
479
  @events.fire_on_booted!
480
+ debug_loaded_extensions("Loaded Extensions - master:") if @log_writer.debug?
481
481
  in_phased_restart = false
482
482
  end
483
483
 
@@ -3,7 +3,7 @@
3
3
  module Puma
4
4
  # Rack::CommonLogger forwards every request to the given +app+, and
5
5
  # logs a line in the
6
- # {Apache common log format}[https://httpd.apache.org/docs/1.3/logs.html#common]
6
+ # {Apache common log format}[https://httpd.apache.org/docs/2.4/logs.html#common]
7
7
  # to the +logger+.
8
8
  #
9
9
  # If +logger+ is nil, CommonLogger will fall back +rack.errors+, which is
@@ -16,7 +16,7 @@ module Puma
16
16
  # (which is called without arguments in order to make the error appear for
17
17
  # sure)
18
18
  class CommonLogger
19
- # Common Log Format: https://httpd.apache.org/docs/1.3/logs.html#common
19
+ # Common Log Format: https://httpd.apache.org/docs/2.4/logs.html#common
20
20
  #
21
21
  # lilith.local - - [07/Aug/2006 23:58:02 -0400] "GET / HTTP/1.1" 500 -
22
22
  #
@@ -25,10 +25,17 @@ module Puma
25
25
 
26
26
  HIJACK_FORMAT = %{%s - %s [%s] "%s %s%s %s" HIJACKED -1 %0.4f\n}
27
27
 
28
- CONTENT_LENGTH = 'Content-Length'.freeze
29
- PATH_INFO = 'PATH_INFO'.freeze
30
- QUERY_STRING = 'QUERY_STRING'.freeze
31
- REQUEST_METHOD = 'REQUEST_METHOD'.freeze
28
+ LOG_TIME_FORMAT = '%d/%b/%Y:%H:%M:%S %z'
29
+
30
+ CONTENT_LENGTH = 'Content-Length' # should be lower case from app,
31
+ # Util::HeaderHash allows mixed
32
+ HTTP_VERSION = Const::HTTP_VERSION
33
+ HTTP_X_FORWARDED_FOR = Const::HTTP_X_FORWARDED_FOR
34
+ PATH_INFO = Const::PATH_INFO
35
+ QUERY_STRING = Const::QUERY_STRING
36
+ REMOTE_ADDR = Const::REMOTE_ADDR
37
+ REMOTE_USER = 'REMOTE_USER'
38
+ REQUEST_METHOD = Const::REQUEST_METHOD
32
39
 
33
40
  def initialize(app, logger=nil)
34
41
  @app = app
@@ -57,13 +64,13 @@ module Puma
57
64
  now = Time.now
58
65
 
59
66
  msg = HIJACK_FORMAT % [
60
- env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
61
- env["REMOTE_USER"] || "-",
62
- now.strftime("%d/%b/%Y %H:%M:%S"),
67
+ env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR] || "-",
68
+ env[REMOTE_USER] || "-",
69
+ now.strftime(LOG_TIME_FORMAT),
63
70
  env[REQUEST_METHOD],
64
71
  env[PATH_INFO],
65
72
  env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
66
- env["HTTP_VERSION"],
73
+ env[HTTP_VERSION],
67
74
  now - began_at ]
68
75
 
69
76
  write(msg)
@@ -74,13 +81,13 @@ module Puma
74
81
  length = extract_content_length(header)
75
82
 
76
83
  msg = FORMAT % [
77
- env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
78
- env["REMOTE_USER"] || "-",
79
- now.strftime("%d/%b/%Y:%H:%M:%S %z"),
84
+ env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR] || "-",
85
+ env[REMOTE_USER] || "-",
86
+ now.strftime(LOG_TIME_FORMAT),
80
87
  env[REQUEST_METHOD],
81
88
  env[PATH_INFO],
82
89
  env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
83
- env["HTTP_VERSION"],
90
+ env[HTTP_VERSION],
84
91
  status.to_s[0..3],
85
92
  length,
86
93
  now - began_at ]
@@ -157,6 +157,7 @@ module Puma
157
157
  reaping_time: 1,
158
158
  remote_address: :socket,
159
159
  silence_single_worker_warning: false,
160
+ silence_fork_callback_warning: false,
160
161
  tag: File.basename(Dir.getwd),
161
162
  tcp_host: '0.0.0.0'.freeze,
162
163
  tcp_port: 9292,
@@ -167,6 +168,7 @@ module Puma
167
168
  worker_shutdown_timeout: 30,
168
169
  worker_timeout: 60,
169
170
  workers: 0,
171
+ http_content_length_limit: nil
170
172
  }
171
173
 
172
174
  def initialize(user_options={}, default_options = {}, &block)