source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
puma/puma
https://github.com/puma/puma
lib/puma/rack_default.rb
Ruby
bsd-3-clause
7,885
main
530
# frozen_string_literal: true require_relative '../rack/handler/puma' # rackup was removed in Rack 3, it is now a separate gem if Object.const_defined? :Rackup module Rackup module Handler def self.default(options = {}) ::Rackup::Handler::Puma end end end elsif Object.const_defined?(:R...
github
puma/puma
https://github.com/puma/puma
lib/puma/detect.rb
Ruby
bsd-3-clause
7,885
main
1,011
# frozen_string_literal: true # This file can be loaded independently of puma.rb, so it cannot have any code # that assumes puma.rb is loaded. module Puma # @version 5.2.1 HAS_FORK = ::Process.respond_to? :fork HAS_NATIVE_IO_WAIT = ::IO.public_instance_methods(false).include? :wait_readable IS_JRUBY = Obje...
github
puma/puma
https://github.com/puma/puma
lib/puma/client_env.rb
Ruby
bsd-3-clause
7,885
main
5,584
# frozen_string_literal: true module Puma #———————————————————————— DO NOT USE — this class is for internal use only ——— # This module is included in `Client`. It contains code to process the `env` # before it is passed to the app. # module ClientEnv # :nodoc: include Puma::Const # Given a Hash...
github
puma/puma
https://github.com/puma/puma
lib/puma/plugin/tmp_restart.rb
Ruby
bsd-3-clause
7,885
main
742
# frozen_string_literal: true require_relative '../plugin' Puma::Plugin.create do def start(launcher) path = File.join("tmp", "restart.txt") orig = nil # If we can't write to the path, then just don't bother with this plugin begin File.write(path, "") unless File.exist?(path) orig = Fi...
github
puma/puma
https://github.com/puma/puma
lib/puma/plugin/systemd.rb
Ruby
bsd-3-clause
7,885
main
2,276
# frozen_string_literal: true require_relative '../plugin' # Puma's systemd integration allows Puma to inform systemd: # 1. when it has successfully started # 2. when it is starting shutdown # 3. periodically for a liveness check with a watchdog thread # 4. periodically set the status Puma::Plugin.create do def...
github
puma/puma
https://github.com/puma/puma
lib/puma/minissl/context_builder.rb
Ruby
bsd-3-clause
7,885
main
3,477
module Puma module MiniSSL class ContextBuilder def initialize(params, log_writer) @params = params @log_writer = log_writer end def context ctx = MiniSSL::Context.new if defined?(JRUBY_VERSION) unless params['keystore'] log_writer.error "P...
github
puma/puma
https://github.com/puma/puma
lib/puma/cluster/worker_handle.rb
Ruby
bsd-3-clause
7,885
main
3,243
# frozen_string_literal: true module Puma class Cluster < Runner #—————————————————————— DO NOT USE — this class is for internal use only ——— # This class represents a worker process from the perspective of the puma # master process. It contains information about the process and its health # and it ...
github
puma/puma
https://github.com/puma/puma
lib/puma/cluster/worker.rb
Ruby
bsd-3-clause
7,885
main
5,903
# frozen_string_literal: true module Puma class Cluster < Puma::Runner #—————————————————————— DO NOT USE — this class is for internal use only ——— # This class is instantiated by the `Puma::Cluster` and represents a single # worker process. # # At the core of this class is running an instance ...
github
puma/puma
https://github.com/puma/puma
lib/puma/rack/urlmap.rb
Ruby
bsd-3-clause
7,885
main
2,658
# frozen_string_literal: true module Puma::Rack # Rack::URLMap takes a hash mapping urls or paths to apps, and # dispatches accordingly. Support for HTTP/1.1 host names exists if # the URLs start with <tt>http://</tt> or <tt>https://</tt>. # # URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part...
github
puma/puma
https://github.com/puma/puma
lib/puma/rack/builder.rb
Ruby
bsd-3-clause
7,885
main
8,387
# frozen_string_literal: true module Puma end module Puma::Rack class Options def parse!(args) options = {} opt_parser = OptionParser.new("", 24, ' ') do |opts| opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]" opts.separator "" opts.separator "Rub...
github
puma/puma
https://github.com/puma/puma
lib/puma/launcher/bundle_pruner.rb
Ruby
bsd-3-clause
7,885
main
2,901
# frozen_string_literal: true module Puma class Launcher # This class is used to pickup Gemfile changes during # application restarts. class BundlePruner def initialize(original_argv, extra_runtime_dependencies, log_writer) @original_argv = Array(original_argv) @extra_runtime_depe...
github
puma/puma
https://github.com/puma/puma
lib/puma/app/status.rb
Ruby
bsd-3-clause
7,885
main
3,102
# frozen_string_literal: true require_relative '../json_serialization' module Puma module App # Check out {#call}'s source code to see what actions this web application # can respond to. class Status OK_STATUS = '{ "status": "ok" }'.freeze READ_ONLY_COMMANDS = %w[gc-stats stats].freeze ...
github
puma/puma
https://github.com/puma/puma
lib/rack/handler/puma.rb
Ruby
bsd-3-clause
7,885
main
4,337
# frozen_string_literal: true module Puma # This module is used as an 'include' file in code at bottom of file. It loads # into either `Rackup::Handler::Puma` or `Rack::Handler::Puma`. module RackHandler DEFAULT_OPTIONS = { :Verbose => false, :Silent => false } def config(app, options...
github
puma/puma
https://github.com/puma/puma
ext/puma_http11/extconf.rb
Ruby
bsd-3-clause
7,885
main
2,282
require 'mkmf' dir_config("puma_http11") if $mingw append_cflags '-fstack-protector-strong -D_FORTIFY_SOURCE=2' append_ldflags '-fstack-protector-strong -l:libssp.a' have_library 'ssp' end unless ENV["PUMA_DISABLE_SSL"] # don't use pkg_config('openssl') if '--with-openssl-dir' is used has_openssl_dir = di...
github
puma/puma
https://github.com/puma/puma
tools/trickletest.rb
Ruby
bsd-3-clause
7,885
main
887
require 'socket' require 'stringio' def do_test(st, chunk) s = TCPSocket.new('127.0.0.1',ARGV[0].to_i); req = StringIO.new(st) nout = 0 randstop = rand(st.length / 10) STDERR.puts "stopping after: #{randstop}" begin while data = req.read(chunk) nout += s.write(data) s.flush sleep 0.1...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/response_time_wrk.rb
Ruby
bsd-3-clause
7,885
main
7,275
# frozen_string_literal: true require_relative 'bench_base' require_relative 'puma_info' module TestPuma # This file is called from `response_time_wrk.sh`. It requires `wrk`. # We suggest using https://github.com/ioquatix/wrk # # It starts a `Puma` server, then collects data from one or more runs of wrk. ...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/puma_info.rb
Ruby
bsd-3-clause
7,885
main
5,441
# frozen_string_literal: true require 'optparse' require_relative '../../lib/puma/state_file' require_relative '../../lib/puma/const' require_relative '../../lib/puma/detect' require_relative '../../lib/puma/configuration' require 'uri' require 'socket' require 'json' module TestPuma # Similar to puma_ctl.rb, but ...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/sleep_fibonacci_test.rb
Ruby
bsd-3-clause
7,885
main
2,336
# frozen_string_literal: true =begin change to benchmarks/local folder ruby sleep_fibonacci_test.rb s ruby sleep_fibonacci_test.rb m ruby sleep_fibonacci_test.rb l ruby sleep_fibonacci_test.rb a ruby sleep_fibonacci_test.rb 0.001,0.005,0.01,0.02,0.04 =end module SleepFibonacciTest class << self TIME_RE = / ...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/long_tail_hey.rb
Ruby
bsd-3-clause
7,885
main
7,530
# frozen_string_literal: true require_relative 'bench_base' require_relative 'puma_info' require 'json' module TestPuma # This file is called from `long_tail_hey.sh`. It requires `hey`. # See https://github.com/rakyll/hey. # # It starts a `Puma` server, then collects data from one or more runs of hey. # I...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/bench_base.rb
Ruby
bsd-3-clause
7,885
main
13,335
# frozen_string_literal: true require 'optparse' module TestPuma HOST4 = ENV.fetch('PUMA_TEST_HOST4', '127.0.0.1') HOST6 = ENV.fetch('PUMA_TEST_HOST6', '::1') PORT = ENV.fetch('PUMA_TEST_PORT', 40001).to_i # Array of response body sizes. If specified, set by ENV['PUMA_TEST_SIZES'] # SIZES = if (t = EN...
github
puma/puma
https://github.com/puma/puma
benchmarks/local/sinatra/Gemfile
Ruby
bsd-3-clause
7,885
main
303
source "http://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.0" gem "sinatra" gem "puma_worker_killer" # current puma release gem "puma" # PR to reduce memory of large file uploads # gem "puma", github: "willkoehler/puma", branch: "reduce_read_body_memory"
github
puma/puma
https://github.com/puma/puma
benchmarks/local/sinatra/puma.rb
Ruby
bsd-3-clause
7,885
main
348
silence_single_worker_warning workers 1 before_fork do require "puma_worker_killer" PumaWorkerKiller.config do |config| config.ram = 1024 # mb config.frequency = 0.3 # seconds config.reaper_status_logs = true # Log memory: PumaWorkerKiller: Consuming 54.34765625 mb with master and 1 workers. end ...
github
puma/puma
https://github.com/puma/puma
test/test_rack_handler.rb
Ruby
bsd-3-clause
7,885
main
10,224
# frozen_string_literal: true require_relative "helper" # Most tests check that ::Rack::Handler::Puma works by itself # RackUp#test_bin runs Puma using the rackup bin file module TestRackUp require "rack/handler/puma" require "puma/events" begin require 'rackup/version' rescue LoadError end class T...
github
puma/puma
https://github.com/puma/puma
test/test_web_server.rb
Ruby
bsd-3-clause
7,885
main
3,635
# frozen_string_literal: true # Copyright (c) 2011 Evan Phoenix # Copyright (c) 2005 Zed A. Shaw require_relative "helper" require "puma/server" class TestHandler attr_reader :ran_test def call(env) @ran_test = true [200, {"Content-Type" => "text/plain"}, ["hello!"]] end end class WebServerTest < Pu...
github
puma/puma
https://github.com/puma/puma
test/test_json_serialization.rb
Ruby
bsd-3-clause
7,885
main
3,123
# frozen_string_literal: true require_relative "helper" require "json" require "puma/json_serialization" class TestJSONSerialization < PumaTest parallelize_me! unless JRUBY_HEAD def test_json_generates_string_for_hash_with_string_keys value = { "key" => "value" } assert_puma_json_generates_string '{"key"...
github
puma/puma
https://github.com/puma/puma
test/test_puma_localhost_authority.rb
Ruby
bsd-3-clause
7,885
main
2,324
# frozen_string_literal: true # Nothing in this file runs if Puma isn't compiled with ssl support # # helper is required first since it loads Puma, which needs to be # loaded so HAS_SSL is defined require_relative "helper" require "localhost/authority" if ::Puma::HAS_SSL && !Puma::IS_JRUBY require "puma/minissl" ...
github
puma/puma
https://github.com/puma/puma
test/test_integration_pumactl.rb
Ruby
bsd-3-clause
7,885
main
8,613
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestIntegrationPumactl < TestIntegration include TmpPath parallelize_me! def workers ; 2 ; end def setup super @state_path = tmp_path('.state') end def test_stop_tcp skip_if :jruby, :truffle...
github
puma/puma
https://github.com/puma/puma
test/test_request_invalid_multiple.rb
Ruby
bsd-3-clause
7,885
main
6,321
# frozen_string_literal: true require_relative "helper" require_relative "helpers/test_puma/puma_socket" # These tests check for invalid request headers and metadata. # Content-Length, Transfer-Encoding, and chunked body size # values are checked for validity # # See https://httpwg.org/specs/rfc9112.html # # https://...
github
puma/puma
https://github.com/puma/puma
test/test_cluster_accept_loop_delay.rb
Ruby
bsd-3-clause
7,885
main
2,673
# frozen_string_literal: true require_relative "helper" require "puma/cluster_accept_loop_delay" class TestClusterAcceptLoopDelay < PumaTest parallelize_me! def test_off_when_fewer_than_two_workers cal_delay = Puma::ClusterAcceptLoopDelay.new( workers: 2, max_delay: 1 ) assert_equal true,...
github
puma/puma
https://github.com/puma/puma
test/test_config.rb
Ruby
bsd-3-clause
7,885
main
34,813
# frozen_string_literal: true require_relative "helper" require "puma/configuration" require 'puma/log_writer' require 'rack' class TestConfigFile < PumaTest parallelize_me! def test_default_max_threads max_threads = 16 max_threads = 5 if RUBY_ENGINE.nil? || RUBY_ENGINE == 'ruby' conf = Puma::Config...
github
puma/puma
https://github.com/puma/puma
test/test_integration_ssl.rb
Ruby
bsd-3-clause
7,885
main
8,788
# frozen_string_literal: true require_relative 'helper' require_relative "helpers/integration" if ::Puma::HAS_SSL # don't load any files if no ssl support require "net/http" require "openssl" require_relative "helpers/test_puma/puma_socket" end # These tests are used to verify that Puma works with SSL sockets....
github
puma/puma
https://github.com/puma/puma
test/test_unix_socket.rb
Ruby
bsd-3-clause
7,885
main
1,085
# frozen_string_literal: true require_relative "helper" require_relative "helpers/tmp_path" class TestPumaUnixSocket < PumaTest include TmpPath App = lambda { |env| [200, {}, ["Works"]] } def teardown return if skipped? @server.stop(true) end def server_unix(type) @tmp_socket_path = type == :...
github
puma/puma
https://github.com/puma/puma
test/test_example_cert_expiration.rb
Ruby
bsd-3-clause
7,885
main
1,398
# frozen_string_literal: true require_relative 'helper' require 'openssl' # # Thes are tests to ensure that the checked in certs in the ./examples/ # directory are valid and work as expected. # # These tests will start to fail 1 month before the certs expire # class TestExampleCertExpiration < PumaTest EXAMPLES_DIR...
github
puma/puma
https://github.com/puma/puma
test/test_rack_server.rb
Ruby
bsd-3-clause
7,885
main
8,924
# frozen_string_literal: true require_relative "helper" require "net/http" # Don't load Rack, as it autoloads everything begin require "rack/body_proxy" require "rack/lint" require "rack/version" require "rack/common_logger" rescue LoadError # Rack 1.6 require "rack" end # Rack::Chunked is loaded by Rack v...
github
puma/puma
https://github.com/puma/puma
test/test_pumactl.rb
Ruby
bsd-3-clause
7,885
main
10,002
# frozen_string_literal: true require_relative "helper" require_relative "helpers/ssl" require 'pathname' require 'puma/control_cli' class TestPumaControlCli < PumaTest include SSLHelper def setup # use a pipe to get info across thread boundary @wait, @ready = IO.pipe end def wait_booted(log: nil) ...
github
puma/puma
https://github.com/puma/puma
test/test_fiber_storage_application.rb
Ruby
bsd-3-clause
7,885
main
968
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2023, by Samuel Williams. require_relative "helper" require "puma/server" class FiberStorageApplication def call(env) count = (Fiber[:request_count] ||= 0) Fiber[:request_count] += 1 [200, {"Content-Type" => "text/plain"}, [c...
github
puma/puma
https://github.com/puma/puma
test/test_skip_sigusr2.rb
Ruby
bsd-3-clause
7,885
main
636
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" require "puma/plugin" class TestSkipSigusr2 < TestIntegration def setup skip_unless_signal_exist? :TERM skip_unless_signal_exist? :USR2 super end def teardown super unless skipped? end def tes...
github
puma/puma
https://github.com/puma/puma
test/test_puma_server_ssl.rb
Ruby
bsd-3-clause
7,885
main
22,265
# frozen_string_literal: true # Nothing in this file runs if Puma isn't compiled with ssl support # # helper is required first since it loads Puma, which needs to be # loaded so HAS_SSL is defined require_relative "helper" if ::Puma::HAS_SSL require "puma/minissl" require_relative "helpers/test_puma/puma_socket" ...
github
puma/puma
https://github.com/puma/puma
test/test_out_of_band_server.rb
Ruby
bsd-3-clause
7,885
main
3,872
# frozen_string_literal: true require_relative "helper" require_relative "helpers/test_puma/puma_socket" class TestOutOfBandServer < PumaTest parallelize_me! include TestPuma include TestPuma::PumaSocket HOST = HOST4 def setup @host = HOST @server = nil @oob_finished = ConditionVariable.new ...
github
puma/puma
https://github.com/puma/puma
test/test_puma_server_shutdown_debug.rb
Ruby
bsd-3-clause
7,885
main
2,895
# frozen_string_literal: true require "puma/events" require_relative "helper" require_relative "helpers/test_puma" require_relative "helpers/test_puma/puma_socket" require_relative "helpers/test_puma/shutdown_requests" class TestPumaServerShutdownDebug < PumaTest include TestPuma include TestPuma::PumaSocket i...
github
puma/puma
https://github.com/puma/puma
test/test_app_status.rb
Ruby
bsd-3-clause
7,885
main
2,240
# frozen_string_literal: true require_relative "helper" require "puma/app/status" require "rack" class TestAppStatus < PumaTest class FakeServer def initialize @status = :running end attr_reader :status def stop @status = :stop end def halt @status = :halt end ...
github
puma/puma
https://github.com/puma/puma
test/test_fiber_local_application.rb
Ruby
bsd-3-clause
7,885
main
952
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2023, by Samuel Williams. require_relative "helper" require "puma/server" class FiberLocalApplication def call(env) # Just in case you didn't know, this is fiber local... count = (Thread.current[:request_count] ||= 0) Thread....
github
puma/puma
https://github.com/puma/puma
test/test_skip_systemd.rb
Ruby
bsd-3-clause
7,885
main
656
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" require "puma/plugin" class TestSkipSystemd < TestIntegration def setup skip_unless :linux skip_if :jruby super end def teardown super unless skipped? end def test_systemd_plugin_not_loaded ...
github
puma/puma
https://github.com/puma/puma
test/test_puma_server_hijack.rb
Ruby
bsd-3-clause
7,885
main
5,782
# frozen_string_literal: true require_relative "helper" require_relative "helpers/test_puma/puma_socket" require "puma/events" require "puma/server" require "net/http" require "nio" require "rack" require "rack/body_proxy" # Tests check both the proper passing of the socket to the app, and also calling # of `body.cl...
github
puma/puma
https://github.com/puma/puma
test/test_integration_single.rb
Ruby
bsd-3-clause
7,885
main
8,299
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestIntegrationSingle < TestIntegration parallelize_me! def workers ; 0 ; end def test_hot_restart_does_not_drop_connections_threads ttl_reqs = Puma.windows? ? 500 : 1_000 restart_does_not_drop_connect...
github
puma/puma
https://github.com/puma/puma
test/test_plugin_systemd_jruby.rb
Ruby
bsd-3-clause
7,885
main
626
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" require "puma/plugin" class TestPluginSystemdJruby < TestIntegration def setup skip_unless :linux skip_unless :jruby super end def teardown super unless skipped? end def test_systemd_plugin_no...
github
puma/puma
https://github.com/puma/puma
test/test_null_io.rb
Ruby
bsd-3-clause
7,885
main
3,881
# frozen_string_literal: true require_relative "helper" require "puma/null_io" class TestNullIO < PumaTest parallelize_me! attr_accessor :nio def setup self.nio = Puma::NullIO.new end def test_eof_returns_true assert nio.eof? end def test_gets_returns_nil assert_nil nio.gets end de...
github
puma/puma
https://github.com/puma/puma
test/test_helper.rb
Ruby
bsd-3-clause
7,885
main
535
# frozen_string_literal: true require_relative "helper" class TestHelper < PumaTest def test_with_temp_env original_puma_debug_env = ENV["PUMA_DEBUG"] with_temp_env({ "PUMA_DEBUG": "1" }, { "APP_ENV" => "test" }) do refute_equal original_puma_debug_env, ENV["PUMA_DEBUG"] assert_equal "1", ENV["...
github
puma/puma
https://github.com/puma/puma
test/test_bundle_pruner.rb
Ruby
bsd-3-clause
7,885
main
1,887
# frozen_string_literal: true require_relative 'helper' require 'puma/events' class TestBundlePruner < PumaTest PUMA_VERS = "puma-#{Puma::Const::PUMA_VERSION}" def test_paths_to_require_after_prune_is_correctly_built_for_no_extra_deps skip_if :no_bundler dirs = bundle_pruner.send(:paths_to_require_aft...
github
puma/puma
https://github.com/puma/puma
test/test_integration_ssl_session.rb
Ruby
bsd-3-clause
7,885
main
4,490
# frozen_string_literal: true require_relative 'helper' require_relative 'helpers/integration' # These tests are used to verify that Puma works with SSL sockets. Only # integration tests isolate the server from the test environment, so there # should be a few SSL tests. # # For instance, since other tests make use o...
github
puma/puma
https://github.com/puma/puma
test/test_binder.rb
Ruby
bsd-3-clause
7,885
main
17,057
# frozen_string_literal: true require_relative "helper" require_relative "helpers/ssl" if ::Puma::HAS_SSL require_relative "helpers/tmp_path" require "puma/binder" require "puma/events" require "puma/configuration" class TestBinderBase < PumaTest include SSLHelper if ::Puma::HAS_SSL include TmpPath def setup ...
github
puma/puma
https://github.com/puma/puma
test/helper.rb
Ruby
bsd-3-clause
7,885
main
11,710
# frozen_string_literal: true # Copyright (c) 2011 Evan Phoenix # Copyright (c) 2005 Zed A. Shaw # WIth GitHub Actions, OS's `/tmp` folder may be on a HDD, while # ENV['RUNNER_TEMP'] is an SSD. Faster. if ENV['GITHUB_ACTIONS'] == 'true' ENV['TMPDIR'] = ENV['RUNNER_TEMP'] end if Process.respond_to?(:getrlimit) so...
github
puma/puma
https://github.com/puma/puma
test/test_url_map.rb
Ruby
bsd-3-clause
7,885
main
694
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestURLMap < TestIntegration def teardown return if skipped? super end # make sure the mapping defined in url_map_test/config.ru works def test_basic_url_mapping skip_if :jruby env = { "BUNDL...
github
puma/puma
https://github.com/puma/puma
test/test_launcher.rb
Ruby
bsd-3-clause
7,885
main
3,562
# frozen_string_literal: true require_relative "helper" require_relative "helpers/tmp_path" require "puma/configuration" require 'puma/log_writer' # Do not add any tests creating workers to this, as Cluster may call `Process.waitall`, # which may cause issues in the test process. # Intermittent failures & errors wh...
github
puma/puma
https://github.com/puma/puma
test/test_plugin.rb
Ruby
bsd-3-clause
7,885
main
589
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestPlugin < TestIntegration def test_plugin Dir.mkdir("tmp") unless Dir.exist?("tmp") cli_server "#{set_pumactl_args} test/rackup/hello.ru", config: "plugin 'tmp_restart'" File.open('tmp/restart...
github
puma/puma
https://github.com/puma/puma
test/test_web_concurrency_auto.rb
Ruby
bsd-3-clause
7,885
main
1,740
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" require_relative "helpers/test_puma/puma_socket" require "puma/configuration" require 'puma/log_writer' class TestWebConcurrencyAuto < TestIntegration include TestPuma::PumaSocket ENV_WC_TEST = { # -W0 removes l...
github
puma/puma
https://github.com/puma/puma
test/test_puma_server.rb
Ruby
bsd-3-clause
7,885
main
63,866
# frozen_string_literal: true require_relative "helper" require_relative "helpers/test_puma/puma_socket" require_relative "helpers/test_puma/shutdown_requests" require "puma/events" require "puma/server" require "nio" require "ipaddr" class WithoutBacktraceError < StandardError def backtrace; nil; end def message...
github
puma/puma
https://github.com/puma/puma
test/test_worker_gem_independence.rb
Ruby
bsd-3-clause
7,885
main
5,934
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestWorkerGemIndependence < TestIntegration ENV_RUBYOPT = { 'RUBYOPT' => ENV['RUBYOPT'] } def setup skip_unless :fork super end def teardown return if skipped? FileUtils.rm current_rel...
github
puma/puma
https://github.com/puma/puma
test/test_thread_pool.rb
Ruby
bsd-3-clause
7,885
main
10,731
# frozen_string_literal: true require_relative "helper" require "puma/thread_pool" class TestThreadPool < PumaTest parallelize_me! def teardown @pool.shutdown(1) if defined?(@pool) end def new_pool(min, max, max_io_threads: 0, pool_shutdown_grace_time: nil, &block) block = proc { } unless block ...
github
puma/puma
https://github.com/puma/puma
test/test_persistent.rb
Ruby
bsd-3-clause
7,885
main
6,451
# frozen_string_literal: true require_relative "helper" require_relative "helpers/test_puma/puma_socket" class TestPersistent < PumaTest parallelize_me! include ::TestPuma::PumaSocket HOST = "127.0.0.1" def setup @body = ["Hello"] @valid_request = "GET / HTTP/1.1\r\nHost: test.com\r\nContent-Type...
github
puma/puma
https://github.com/puma/puma
test/test_events.rb
Ruby
bsd-3-clause
7,885
main
2,310
# frozen_string_literal: true require 'puma/events' require_relative "helper" class TestEvents < PumaTest def test_register_callback_with_block res = false events = Puma::Events.new events.register(:exec) { res = true } events.fire(:exec) assert_equal true, res end def test_register_cal...
github
puma/puma
https://github.com/puma/puma
test/test_redirect_io.rb
Ruby
bsd-3-clause
7,885
main
2,194
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestRedirectIO < TestIntegration # takes longer (or same) when run parallel FILE_STR = 'puma startup' def setup skip_unless_signal_exist? :HUP super # Keep the Tempfile instances alive to avoid be...
github
puma/puma
https://github.com/puma/puma
test/test_puma_server_current.rb
Ruby
bsd-3-clause
7,885
main
1,084
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2023, by Samuel Williams. require_relative "helper" require "puma/server" class PumaServerCurrentApplication def call(env) [200, {"Content-Type" => "text/plain"}, [Puma::Server.current.to_s]] end end class PumaServerCurrentTest < ...
github
puma/puma
https://github.com/puma/puma
test/test_http11.rb
Ruby
bsd-3-clause
7,885
main
9,610
# frozen_string_literal: true # Copyright (c) 2011 Evan Phoenix # Copyright (c) 2005 Zed A. Shaw require_relative "helper" require_relative "helpers/integration" require "digest" require "puma/puma_http11" class Http11ParserTest < TestIntegration parallelize_me! unless ::Puma::IS_JRUBY && RUBY_DESCRIPTION.includ...
github
puma/puma
https://github.com/puma/puma
test/test_error_logger.rb
Ruby
bsd-3-clause
7,885
main
2,731
# frozen_string_literal: true require 'puma/error_logger' require_relative "helper" class TestErrorLogger < PumaTest Req = Struct.new(:env, :body) def test_stdio error_logger = Puma::ErrorLogger.stdio assert_equal STDERR, error_logger.ioerr end def test_stdio_respects_sync error_logger = Puma:...
github
puma/puma
https://github.com/puma/puma
test/test_request_single.rb
Ruby
bsd-3-clause
7,885
main
21,213
# frozen_string_literal: true require_relative "helper" require 'puma/client' # this file tests both valid and invalid requests using only `Puma::Client'. # It cannot test behavior with multiple requests, for that, see # `test_request_invalid_multiple.rb` class TestRequestBase < PumaTest include Puma::Const P...
github
puma/puma
https://github.com/puma/puma
test/test_integration_cluster.rb
Ruby
bsd-3-clause
7,885
main
26,958
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" require "puma/configuration" require "time" class TestIntegrationCluster < TestIntegration parallelize_me! def workers ; 2 ; end def setup skip_unless :fork super end def teardown return if skippe...
github
puma/puma
https://github.com/puma/puma
test/test_iobuffer.rb
Ruby
bsd-3-clause
7,885
main
799
# frozen_string_literal: true require_relative "helper" require "puma/io_buffer" class TestIOBuffer < PumaTest attr_accessor :iobuf def setup self.iobuf = Puma::IOBuffer.new end def test_initial_size assert_equal 0, iobuf.size end def test_append_op iobuf << "abc" assert_equal "abc", io...
github
puma/puma
https://github.com/puma/puma
test/test_preserve_bundler_env.rb
Ruby
bsd-3-clause
7,885
main
3,157
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestPreserveBundlerEnv < TestIntegration def setup skip_unless :fork super end def teardown return if skipped? FileUtils.rm current_release_symlink, force: true super end # It does not ...
github
puma/puma
https://github.com/puma/puma
test/test_http10.rb
Ruby
bsd-3-clause
7,885
main
869
# frozen_string_literal: true require_relative "helper" require "puma/puma_http11" class Http10ParserTest < PumaTest def test_parse_simple parser = Puma::HttpParser.new req = {} http = "GET / HTTP/1.0\r\n\r\n" nread = parser.execute(req, http, 0) assert nread == http.length, "Failed to parse t...
github
puma/puma
https://github.com/puma/puma
test/test_state_file.rb
Ruby
bsd-3-clause
7,885
main
579
# frozen_string_literal: true require_relative "helper" require_relative "helpers/tmp_path" require 'puma/state_file' class TestStateFile < PumaTest include TmpPath def test_load_empty_value_as_nil state_path = tmp_path('.state') File.write state_path, <<-STATE --- pid: 123456 control_url: control_auth_...
github
puma/puma
https://github.com/puma/puma
test/test_minissl.rb
Ruby
bsd-3-clause
7,885
main
3,070
require_relative "helper" require "puma/minissl" if ::Puma::HAS_SSL class TestMiniSSL < PumaTest if Puma.jruby? def test_raises_with_invalid_keystore_file ctx = Puma::MiniSSL::Context.new exception = assert_raises(ArgumentError) { ctx.keystore = "/no/such/keystore" } assert_equal("Keystore f...
github
puma/puma
https://github.com/puma/puma
test/test_log_writer.rb
Ruby
bsd-3-clause
7,885
main
4,744
require 'puma/detect' require 'puma/log_writer' require_relative "helper" class TestLogWriter < PumaTest def test_null log_writer = Puma::LogWriter.null assert_instance_of Puma::NullIO, log_writer.stdout assert_instance_of Puma::NullIO, log_writer.stderr assert_equal log_writer.stdout, log_writer.st...
github
puma/puma
https://github.com/puma/puma
test/test_plugin_systemd.rb
Ruby
bsd-3-clause
7,885
main
3,101
# frozen_string_literal: true require_relative "helper" require_relative "helpers/integration" class TestPluginSystemd < TestIntegration parallelize_me! if ::Puma::IS_MRI THREAD_LOG = TRUFFLE ? "{ 0/16 threads, 16 available, 0 backlog }" : "{ 0/5 threads, 5 available, 0 backlog }" def setup skip_unles...
github
puma/puma
https://github.com/puma/puma
test/test_cli.rb
Ruby
bsd-3-clause
7,885
main
11,145
# frozen_string_literal: true require_relative "helper" require_relative "helpers/ssl" if ::Puma::HAS_SSL require_relative "helpers/tmp_path" require_relative "helpers/test_puma/puma_socket" require "puma/cli" require "json" require "psych" class TestCLI < PumaTest include SSLHelper if ::Puma::HAS_SSL include Tm...
github
puma/puma
https://github.com/puma/puma
test/test_response_header.rb
Ruby
bsd-3-clause
7,885
main
4,910
# frozen_string_literal: true require_relative "helper" require "puma/events" require "net/http" require "nio" class TestResponseHeader < PumaTest parallelize_me! # this file has limited response length, so 10kB works. CLIENT_SYSREAD_LENGTH = 10_240 def setup @host = "127.0.0.1" @ios = [] @app...
github
puma/puma
https://github.com/puma/puma
test/minitest/verbose_progress_plugin.rb
Ruby
bsd-3-clause
7,885
main
935
module Minitest # Adds minimal support for parallel tests to the default verbose progress reporter. def self.plugin_verbose_progress_init(options) if options[:verbose] self.reporter.reporters. delete_if {|r| r.is_a?(ProgressReporter)}. push(VerboseProgressReporter.new(options[:io], options...
github
puma/puma
https://github.com/puma/puma
test/config/state_file_testing_config.rb
Ruby
bsd-3-clause
7,885
main
303
pidfile "t3-pid" workers 3 before_worker_boot do |index| File.open("t3-worker-#{index}-pid", "w") { |f| f.puts Process.pid } end before_fork { 1 } before_worker_shutdown { 1 } before_worker_boot { 1 } before_worker_fork { 1 } before_restart { 1 } after_worker_boot { 1 } lowlevel_error_handler { 1 }
github
puma/puma
https://github.com/puma/puma
test/config/t4_conf.rb
Ruby
bsd-3-clause
7,885
main
264
stdout_redirect "t4-stdout" pidfile "t4-pid" class CustomLogger def initialize(output=STDOUT) @output = output end def write(msg) @output.puts 'Custom logging: ' + msg @output.flush end end log_requests custom_logger CustomLogger.new(STDOUT)
github
puma/puma
https://github.com/puma/puma
test/config/ssl_config.rb
Ruby
bsd-3-clause
7,885
main
428
key = File.expand_path "../../../examples/puma/puma_keypair.pem", __FILE__ cert = File.expand_path "../../../examples/puma/cert_puma.pem", __FILE__ ca = File.expand_path "../../../examples/puma/client_certs/ca.crt", __FILE__ ssl_bind "0.0.0.0", 9292, :cert => cert, :key => key, :verify_mode => "peer", :ca => ca app ...
github
puma/puma
https://github.com/puma/puma
test/config/custom_logger.rb
Ruby
bsd-3-clause
7,885
main
219
class CustomLogger def initialize(output=STDOUT) @output = output end def write(msg) @output.puts 'Custom logging: ' + msg @output.flush end end log_requests custom_logger CustomLogger.new(STDOUT)
github
puma/puma
https://github.com/puma/puma
test/config/ab_rs.rb
Ruby
bsd-3-clause
7,885
main
412
url = ARGV.shift count = (ARGV.shift || 1000).to_i STDOUT.sync = true 1.upto(5) do |i| print "#{i}: " str = `ab -n #{count} -c #{i} #{url} 2>/dev/null` rs = /Requests per second:\s+([\d.]+)\s/.match(str) puts rs[1] end puts "Keep Alive:" 1.upto(5) do |i| print "#{i}: " str = `ab -n #{count} -k -c #{i} ...
github
puma/puma
https://github.com/puma/puma
test/config/process_detach_before_fork.rb
Ruby
bsd-3-clause
7,885
main
240
worker_shutdown_timeout 0 before_fork do pid = fork do sleep 30 # This has to exceed the test timeout end pid_filename = File.join(Dir.tmpdir, 'process_detach_test.pid') File.write(pid_filename, pid) Process.detach(pid) end
github
puma/puma
https://github.com/puma/puma
test/config/cpu_spin.rb
Ruby
bsd-3-clause
7,885
main
511
# call with "GET /cpu/<d> HTTP/1.1\r\n\r\n", # where <d> is the number of iterations require 'benchmark' # configure `wait_for_less_busy_workers` based on ENV, default `true` wait_for_less_busy_worker ENV.fetch('PUMA_WAIT_FOR_LESS_BUSY_WORKERS', '0.005').to_f app do |env| iterations = (env['REQUEST_PATH'][/\/cpu\/...
github
puma/puma
https://github.com/puma/puma
test/helpers/tmp_path.rb
Ruby
bsd-3-clause
7,885
main
912
# frozen_string_literal: true module TmpPath def clean_tmp_paths while path = tmp_paths.pop delete_tmp_path(path) end end private # With some macOS configurations, the following error may be raised when # creating a UNIXSocket: # # too long unix socket path (106 bytes given but 104 bytes ...
github
puma/puma
https://github.com/puma/puma
test/helpers/ssl.rb
Ruby
bsd-3-clause
7,885
main
1,189
# frozen_string_literal: true module SSLHelper def ssl_query @ssl_query ||= if Puma.jruby? @keystore = File.expand_path "../../examples/puma/keystore.jks", __dir__ @ssl_cipher_list = "TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" "keystore=#{@keystore}&keystore-pass=jr...
github
puma/puma
https://github.com/puma/puma
test/helpers/apps.rb
Ruby
bsd-3-clause
7,885
main
339
# frozen_string_literal: true module TestApps # call with "GET /sleep<d> HTTP/1.1\r\n\r\n", where is the number of # seconds to sleep # same as rackup/sleep.ru SLEEP = -> (env) do dly = (env['REQUEST_PATH'][/\/sleep(\d+)/,1] || '0').to_i sleep dly [200, {"Content-Type" => "text/plain"}, ["Slept #{...
github
puma/puma
https://github.com/puma/puma
test/helpers/integration.rb
Ruby
bsd-3-clause
7,885
main
19,741
# frozen_string_literal: true require "puma/control_cli" require "json" require "open3" require_relative 'tmp_path' # Only single mode tests go here. Cluster and pumactl tests # have their own files, use those instead class TestIntegration < PumaTest include TmpPath HOST = "127.0.0.1" TOKEN = "xxyyzz" RESP_R...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma.rb
Ruby
bsd-3-clause
7,885
main
1,471
# frozen_string_literal: true require 'socket' module TestPuma RESP_SPLIT = "\r\n\r\n" LINE_SPLIT = "\r\n" RE_HOST_TO_IP = /\A\[|\]\z/o HOST4 = begin t = Socket.ip_address_list.select(&:ipv4_loopback?).map(&:ip_address) .uniq.sort_by(&:length) # puts "IPv4 Loopback #{t}" str = t.include?(...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma/shutdown_requests.rb
Ruby
bsd-3-clause
7,885
main
2,213
# frozen_string_literal: true require_relative "../test_puma" module TestPuma module ShutdownRequests def shutdown_requests(s1_complete: true, s1_response: nil, post: false, s2_response: nil, **options) mutex = Mutex.new app_finished = ConditionVariable.new server_run(**options) { |env| ...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma/response.rb
Ruby
bsd-3-clause
7,885
main
1,548
# frozen_string_literal: true module TestPuma # A subclass of String, allows processing the response returned by # `PumaSocket#send_http_read_response` and the `PumaSocketInclude#read_response` # method included in the socket classes (created with `PumaSocket#new_socket`, # `PumaSocket#send_http`, and `PumaSo...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma/puma_socket_include.rb
Ruby
bsd-3-clause
7,885
main
6,957
# frozen_string_literal: true require 'socket' require_relative '../test_puma' require_relative 'response' module TestPuma # @!macro [new] resp # @param timeout: [Float, nil] total socket read timeout, defaults to `RESP_READ_TIMEOUT` # @param len: [ Integer, nil] the `read_nonblock` maxlen, defaults to `RE...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma/puma_socket.rb
Ruby
bsd-3-clause
7,885
main
11,767
# frozen_string_literal: true require 'socket' require_relative '../test_puma' require_relative 'puma_socket_include' require_relative 'response' module TestPuma # @!macro [new] req # @param req [String, GET_11] request path # @!macro [new] skt # @param host [String] tcp/ssl host # @param port [Inte...
github
puma/puma
https://github.com/puma/puma
test/helpers/test_puma/assertions.rb
Ruby
bsd-3-clause
7,885
main
2,121
# frozen_string_literal: true module TestPuma module Assertions # iso8601 2022-12-14T00:05:49Z RE_8601 = /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\z/ def assert_start_with(obj, str, msg = nil) msg = message(msg) { "Expected\n#{obj}\nto start with #{str}" } assert_respond_to obj,...
github
puma/puma
https://github.com/puma/puma
test/rackup/sleep_pid.ru
Ruby
bsd-3-clause
7,885
main
352
# call with "GET /sleep<d> HTTP/1.1\r\n\r\n", where <d> is the number of # seconds to sleep, can be a float or an int, returns process pid regex_delay = /\A\/sleep(\d+(?:\.\d+)?)/ run lambda { |env| delay = (env['REQUEST_PATH'][regex_delay,1] || '0').to_f sleep delay [200, {"Content-Type" => "text/plain"}, ["Sle...
github
puma/puma
https://github.com/puma/puma
test/rackup/ci_chunked.ru
Ruby
bsd-3-clause
7,885
main
1,132
# frozen_string_literal: true # Generates a response with chunked bodies, size set via ENV['CI_BODY_CONF'] or # `Body-Conf` request header. # See 'CI - test/rackup/ci-*.ru files' or docs/test_rackup_ci_files.md require 'securerandom' headers = {} headers['Content-Type'] = 'text/plain; charset=utf-8'.freeze 25.times ...
github
puma/puma
https://github.com/puma/puma
test/rackup/realistic_response.ru
Ruby
bsd-3-clause
7,885
main
252
require 'securerandom' long_header_hash = {} 25.times do |i| long_header_hash["X-My-Header-#{i}"] = SecureRandom.hex(25) end response = SecureRandom.hex(100_000) # A 100kb document run lambda { |env| [200, long_header_hash.dup, [response.dup]] }
github
puma/puma
https://github.com/puma/puma
test/rackup/big_file.ru
Ruby
bsd-3-clause
7,885
main
248
static_file_path = File.join(Dir.tmpdir, "puma-static.txt") File.write(static_file_path, "Hello World" * 100_000) run lambda { |env| f = File.open(static_file_path) [200, {"Content-Type" => "text/plain", "Content-Length" => f.size.to_s}, f] }
github
puma/puma
https://github.com/puma/puma
test/rackup/sleep.ru
Ruby
bsd-3-clause
7,885
main
342
# call with "GET /sleep<d> HTTP/1.1\r\n\r\n", where <d> is the number of # seconds to sleep, can be a float or an int # same as TestApps::SLEEP regex_delay = /\A\/sleep(\d+(?:\.\d+)?)/ run lambda { |env| delay = (env['REQUEST_PATH'][regex_delay,1] || '0').to_f sleep delay [200, {"Content-Type" => "text/plain"}, ...
github
puma/puma
https://github.com/puma/puma
test/rackup/ci_select.ru
Ruby
bsd-3-clause
7,885
main
2,239
# frozen_string_literal: true # Generates a response with various body types and sizes, set via ENV['CI_BODY_CONF'] or # `Body-Conf` request header. # See 'CI - test/rackup/ci-*.ru files' or docs/test_rackup_ci_files.md require 'securerandom' require 'tmpdir' headers = {} headers['Content-Type'] = 'text/plain; chars...