Module: Puma
Overview
This module is used as an ‘include’ file in code at bottom of file
Constant Summary
-
HAS_FORK =
::Process.respond_to? :fork
-
HAS_NATIVE_IO_WAIT =
# File 'lib/puma/detect.rb', line 11::IO.public_instance_methods(false).include? :wait_readable
-
HAS_SSL =
at present,
MiniSSL::Engine
is only defined in extension code (puma_http11), not in minissl.rbconst_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
-
HAS_UNIX_SOCKET =
# File 'lib/puma.rb', line 29Object.const_defined?(:UNIXSocket) && !IS_WINDOWS
-
HTTP_STATUS_CODES =
Every standard HTTP code mapped to the appropriate message. Generated with: curl -s www.iana.org/assignments/http-status-codes/http-status-codes-1.csv | \
ruby -ne 'm = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and \ puts "#{m[1]} => \x27#{m[2].strip}\x27,"'
{ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 103 => 'Early Hints', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 208 => 'Already Reported', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Content Too Large', 414 => 'URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 421 => 'Misdirected Request', 422 => 'Unprocessable Content', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Too Early', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended (OBSOLETED)', 511 => 'Network Authentication Required' }.freeze
-
IS_JRUBY =
# File 'lib/puma/detect.rb', line 13Object.const_defined? :JRUBY_VERSION
-
IS_LINUX =
# File 'lib/puma/detect.rb', line 19!(IS_OSX || IS_WINDOWS)
-
IS_MRI =
RUBY_ENGINE == 'ruby'
-
IS_OSX =
# File 'lib/puma/detect.rb', line 15RUBY_DESCRIPTION.include? 'darwin'
-
IS_WINDOWS =
# File 'lib/puma/detect.rb', line 17RUBY_DESCRIPTION.match?(/mswin|ming|cygwin/)
-
Plugins =
# File 'lib/puma/plugin.rb', line 74PluginRegistry.new
-
STATUS_WITH_NO_ENTITY_BODY =
For some HTTP status codes the client only expects headers.
{ 204 => true, 205 => true, 304 => true }.freeze
Class Attribute Summary
- .abstract_unix_socket? ⇒ Boolean readonly
-
.cli_config
rw
The CLI exports a
Configuration
instance here to allow apps to pick it up. - .forkable? ⇒ Boolean readonly
- .jruby? ⇒ Boolean readonly
- .mri? ⇒ Boolean readonly
- .osx? ⇒ Boolean readonly
- .ssl? ⇒ Boolean readonly
- .stats_object=(val) writeonly
- .windows? ⇒ Boolean readonly
Class Method Summary
Instance Attribute Summary
- #stats_hash readonly
- #stats_object rw
Class Attribute Details
.abstract_unix_socket? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/puma.rb', line 45
def self.abstract_unix_socket? @abstract_unix ||= if HAS_UNIX_SOCKET begin ::UNIXServer.new("\0puma.temp.unix").close true rescue ArgumentError # darwin false end else false end end
.cli_config (rw)
The CLI exports a Configuration
instance here to allow apps to pick it up. An app must load this object conditionally because it is not set if the app is launched via any mechanism other than the CLI
class.
# File 'lib/puma/cli.rb', line 18
attr_accessor :cli_config
.forkable? ⇒ Boolean
(readonly)
# File 'lib/puma/detect.rb', line 42
def self.forkable? HAS_FORK end
.jruby? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/puma/detect.rb', line 24
def self.jruby? IS_JRUBY end
.mri? ⇒ Boolean
(readonly)
# File 'lib/puma/detect.rb', line 37
def self.mri? IS_MRI end
.osx? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/puma/detect.rb', line 28
def self.osx? IS_OSX end
.ssl? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/puma.rb', line 41
def self.ssl? HAS_SSL end
.stats_object=(val) (writeonly)
[ GitHub ]# File 'lib/puma.rb', line 60
def self.stats_object=(val) @get_stats = val end
.windows? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/puma/detect.rb', line 32
def self.windows? IS_WINDOWS end
Class Method Details
.set_thread_name(name)
[ GitHub ]# File 'lib/puma.rb', line 75
def self.set_thread_name(name) Thread.current.name = "puma #{name}" end
.stats
[ GitHub ]# File 'lib/puma.rb', line 65
def self.stats Puma::JSONSerialization.generate @get_stats.stats end
.stats_hash
# File 'lib/puma.rb', line 71
def self.stats_hash @get_stats.stats end
Instance Attribute Details
#stats_hash (readonly)
# File 'lib/puma.rb', line 71
def self.stats_hash @get_stats.stats end
#stats_object (rw)
[ GitHub ]# File 'lib/puma.rb', line 65
def self.stats Puma::JSONSerialization.generate @get_stats.stats end