Module: Puma

Defined in:
lib/puma/java_io_buffer.rb,
lib/puma.rb,
lib/puma/cli.rb,
lib/puma/dsl.rb,
lib/puma/util.rb,
lib/puma/const.rb,
lib/puma/binder.rb,
lib/puma/client.rb,
lib/puma/detect.rb,
lib/puma/events.rb,
lib/puma/plugin.rb,
lib/puma/runner.rb,
lib/puma/server.rb,
lib/puma/single.rb,
lib/puma/cluster.rb,
lib/puma/minissl.rb,
lib/puma/null_io.rb,
lib/puma/reactor.rb,
lib/puma/launcher.rb,
lib/puma/app/status.rb,
lib/puma/convenient.rb,
lib/puma/delegation.rb,
lib/puma/state_file.rb,
lib/puma/tcp_logger.rb,
lib/puma/control_cli.rb,
lib/puma/thread_pool.rb,
lib/puma/commonlogger.rb,
lib/puma/rack/builder.rb,
lib/puma/configuration.rb,
lib/puma/jruby_restart.rb,
ext/puma_http11/puma_http11.c

Overview

Conservative native JRuby/Java implementation of IOBuffer backed by a ByteArrayOutputStream and conversion between Ruby String and Java bytes

Defined Under Namespace

Modules: App, ConfigDefault, Const, Delegation, JRubyRestart, MiniSSL, Rack, Util Classes: Binder, CLI, Client, Cluster, CommonLogger, Configuration, ConnectionError, ControlCLI, DSL, Events, HttpParser, HttpParserError, IOBuffer, JavaIOBuffer, Launcher, NullIO, Plugin, PluginLoader, PluginRegistry, Reactor, Runner, Server, Single, StateFile, TCPLogger, ThreadPool, UnknownPlugin, UnsupportedOption, UserFileDefaultOptions

Constant Summary collapse

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',
  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 => 'Payload Too Large',
  414 => 'URI Too Long',
  415 => 'Unsupported Media Type',
  416 => 'Range Not Satisfiable',
  417 => 'Expectation Failed',
  418 => 'I\'m A Teapot',
  422 => 'Unprocessable Entity',
  423 => 'Locked',
  424 => 'Failed Dependency',
  426 => 'Upgrade Required',
  428 => 'Precondition Required',
  429 => 'Too Many Requests',
  431 => 'Request Header Fields Too Large',
  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',
  511 => 'Network Authentication Required'
}
STATUS_WITH_NO_ENTITY_BODY =

For some HTTP status codes the client only expects headers.

{
  204 => true,
  205 => true,
  304 => true
}
IS_JRUBY =
defined?(JRUBY_VERSION)
IS_WINDOWS =
RUBY_PLATFORM =~ /mswin|ming|cygwin/
Plugins =
PluginRegistry.new

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cli_configObject

The CLI exports its Puma::Configuration object here to allow apps to pick it up. An app needs to use it conditionally though since it is not set if the app is launched via another mechanism than the CLI class.



15
16
17
# File 'lib/puma/cli.rb', line 15

def cli_config
  @cli_config
end

Class Method Details

.jruby?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/puma/detect.rb', line 4

def self.jruby?
  IS_JRUBY
end

.run(opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puma/convenient.rb', line 5

def self.run(opts={})
  cfg = Puma::Configuration.new do |user_config|
    if port = opts[:port]
      user_config.port port
    end

    user_config.quiet

    yield c
  end

  cfg.clamp

  events = Puma::Events.null

  launcher = Puma::Launcher.new cfg, :events => events
  launcher.run
end

.windows?Boolean

Returns:

  • (Boolean)


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

def self.windows?
  IS_WINDOWS
end