Class: Puma::Events

Inherits:
Object
  • Object
show all
Includes:
Const
Defined in:
lib/puma/events.rb

Constant Summary collapse

DEFAULT =
new(STDOUT, STDERR)

Constants included from Const

Const::CGI_VER, Const::CHUNK_SIZE, Const::CONTENT_LENGTH, Const::CONTENT_TYPE, Const::DATE, Const::ERROR_404_RESPONSE, Const::ERROR_503_RESPONSE, Const::ETAG, Const::ETAG_FORMAT, Const::GATEWAY_INTERFACE, Const::GET, Const::HEAD, Const::HOST, Const::HTTP_11, Const::HTTP_HOST, Const::HTTP_IF_MODIFIED_SINCE, Const::HTTP_IF_NONE_MATCH, Const::HTTP_X_FORWARDED_FOR, Const::LAST_MODIFIED, Const::LINE_END, Const::MAX_BODY, Const::MAX_HEADER, Const::PATH_INFO, Const::PERSISTENT_TIMEOUT, Const::PORT_80, Const::PUMA_TMP_BASE, Const::PUMA_VERSION, Const::REDIRECT, Const::REMOTE_ADDR, Const::REQUEST_METHOD, Const::REQUEST_PATH, Const::REQUEST_URI, Const::SCRIPT_NAME, Const::SERVER_NAME, Const::SERVER_PORT, Const::SERVER_PROTOCOL, Const::SERVER_SOFTWARE, Const::SLASH, Const::STATUS_FORMAT, Const::STOP_COMMAND

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout, stderr) ⇒ Events

Returns a new instance of Events.



9
10
11
12
# File 'lib/puma/events.rb', line 9

def initialize(stdout, stderr)
  @stdout = stdout
  @stderr = stderr
end

Instance Attribute Details

#stderrObject (readonly)

Returns the value of attribute stderr.



14
15
16
# File 'lib/puma/events.rb', line 14

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



14
15
16
# File 'lib/puma/events.rb', line 14

def stdout
  @stdout
end

Class Method Details

.stringsObject



32
33
34
# File 'lib/puma/events.rb', line 32

def self.strings
  Events.new StringIO.new, StringIO.new
end

Instance Method Details

#parse_error(server, env, error) ⇒ Object



16
17
18
19
# File 'lib/puma/events.rb', line 16

def parse_error(server, env, error)
  @stderr.puts "#{Time.now}: HTTP parse error, malformed request (#{env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR]}): #{error.inspect}"
  @stderr.puts "#{Time.now}: ENV: #{env.inspect}\n---\n"
end

#unknown_error(server, env, error, kind = "Unknown") ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/puma/events.rb', line 21

def unknown_error(server, env, error, kind="Unknown")
  if error.respond_to? :render
    error.render "#{Time.now}: #{kind} error", @stderr
  else
    @stderr.puts "#{Time.now}: #{kind} error: #{error.inspect}"
    @stderr.puts error.backtrace.join("\n")
  end
end