puma 2.11.3 → 2.12.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.

@@ -1,45 +0,0 @@
1
- require 'rack/commonlogger'
2
-
3
- module Rack
4
- # Patch CommonLogger to use after_reply.
5
- #
6
- # Simply request this file and CommonLogger will be a bit more
7
- # efficient.
8
- class CommonLogger
9
- remove_method :call
10
-
11
- def call(env)
12
- began_at = Time.now
13
- status, header, body = @app.call(env)
14
- header = Utils::HeaderHash.new(header)
15
-
16
- # If we've been hijacked, then output a special line
17
- if env['rack.hijack_io']
18
- log_hijacking(env, 'HIJACK', header, began_at)
19
- elsif ary = env['rack.after_reply']
20
- ary << lambda { log(env, status, header, began_at) }
21
- else
22
- body = BodyProxy.new(body) { log(env, status, header, began_at) }
23
- end
24
-
25
- [status, header, body]
26
- end
27
-
28
- HIJACK_FORMAT = %{%s - %s [%s] "%s %s%s %s" HIJACKED -1 %0.4f\n}
29
-
30
- def log_hijacking(env, status, header, began_at)
31
- now = Time.now
32
-
33
- logger = @logger || env['rack.errors']
34
- logger.write HIJACK_FORMAT % [
35
- env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
36
- env["REMOTE_USER"] || "-",
37
- now.strftime("%d/%b/%Y %H:%M:%S"),
38
- env["REQUEST_METHOD"],
39
- env["PATH_INFO"],
40
- env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"],
41
- env["HTTP_VERSION"],
42
- now - began_at ]
43
- end
44
- end
45
- end