diff --git a/bake.rb b/bake.rb index 52b35d0c..005430fe 100644 --- a/bake.rb +++ b/bake.rb @@ -7,6 +7,6 @@ # # @parameter version [String] The new version number. def after_gem_release_version_increment(version) - context['releases:update'].call(version) - context['utopia:project:readme:update'].call + context["releases:update"].call(version) + context["utopia:project:readme:update"].call end diff --git a/bake/falcon/supervisor.rb b/bake/falcon/supervisor.rb index 5934693f..6084e93b 100644 --- a/bake/falcon/supervisor.rb +++ b/bake/falcon/supervisor.rb @@ -4,7 +4,7 @@ # Copyright, 2020-2023, by Samuel Williams. def restart - require_relative '../../lib/falcon/command/supervisor' + require_relative "../../lib/falcon/command/supervisor" Falcon::Command::Supervisor["restart"].call end diff --git a/bin/falcon b/bin/falcon index 5e6dcc0f..58e9e6d8 100755 --- a/bin/falcon +++ b/bin/falcon @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require_relative '../lib/falcon/command' +require_relative "../lib/falcon/command" begin Falcon::Command.call diff --git a/bin/falcon-host b/bin/falcon-host index 548bf795..8c1cad27 100755 --- a/bin/falcon-host +++ b/bin/falcon-host @@ -21,7 +21,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require_relative '../lib/falcon/command/host' +require_relative "../lib/falcon/command/host" begin Falcon::Command::Host.call diff --git a/config/sus.rb b/config/sus.rb index 871a42bc..2016a2c6 100644 --- a/config/sus.rb +++ b/config/sus.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2017-2024, by Samuel Williams. -require 'covered/sus' +require "covered/sus" include Covered::Sus -require 'openssl' +require "openssl" $stderr.puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}" diff --git a/examples/async-service/hello.rb b/examples/async-service/hello.rb index 700cb080..f3390f85 100755 --- a/examples/async-service/hello.rb +++ b/examples/async-service/hello.rb @@ -4,7 +4,7 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'falcon/environment/server' +require "falcon/environment/server" service "hello-server" do include Falcon::Environment::Server diff --git a/examples/beer/config.ru b/examples/beer/config.ru index 36c7eb6e..03ad7e7a 100755 --- a/examples/beer/config.ru +++ b/examples/beer/config.ru @@ -1,8 +1,8 @@ #!/usr/bin/env falcon --verbose serve -c # frozen_string_literal: true -require 'rack' -require 'cgi' +require "rack" +require "cgi" def bottles(n) n == 1 ? "#{n} bottle" : "#{n} bottles" @@ -19,7 +19,7 @@ run lambda {|env| body = Async::HTTP::Body::Writable.new request = Rack::Request.new(env) - count = (request.params['count'] || 99).to_i + count = (request.params["count"] || 99).to_i body.write("#{count} Bottles of Beer") @@ -53,5 +53,5 @@ run lambda {|env| end end - [200, {'content-type' => 'text/html; charset=utf-8'}, body] + [200, {"content-type" => "text/html; charset=utf-8"}, body] } diff --git a/examples/beer/falcon.rb b/examples/beer/falcon.rb index acd783ff..9d6d3c97 100755 --- a/examples/beer/falcon.rb +++ b/examples/beer/falcon.rb @@ -6,6 +6,6 @@ load :rack, :self_signed_tls, :supervisor -rack 'beer.localhost', :self_signed_tls +rack "beer.localhost", :self_signed_tls supervisor diff --git a/examples/benchmark/bake.rb b/examples/benchmark/bake.rb index 733236b7..e38d523e 100644 --- a/examples/benchmark/bake.rb +++ b/examples/benchmark/bake.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'etc' +require "etc" -require 'async' -require 'async/process' -require 'async/clock' -require 'async/http/endpoint' +require "async" +require "async/process" +require "async/clock" +require "async/http/endpoint" def hello @config_path = File.expand_path("../hello/config.ru", __dir__) diff --git a/examples/benchmark/config.ru b/examples/benchmark/config.ru index 9c5fb503..0df4c993 100644 --- a/examples/benchmark/config.ru +++ b/examples/benchmark/config.ru @@ -7,10 +7,10 @@ class Benchmark end def hello(env) - [200, {'content-length' => 12}, ["Hello World\n"]] + [200, {"content-length" => 12}, ["Hello World\n"]] end - PATH_INFO = 'PATH_INFO'.freeze + PATH_INFO = "PATH_INFO".freeze SMALL = [200, {}, ["Hello World\n" * 10] * 10].freeze diff --git a/examples/benchmark/falcon.rb b/examples/benchmark/falcon.rb index ea3caf36..6eda207f 100755 --- a/examples/benchmark/falcon.rb +++ b/examples/benchmark/falcon.rb @@ -6,4 +6,4 @@ load :rack, :self_signed_tls, :supervisor -rack 'benchmark.local', :self_signed_tls +rack "benchmark.local", :self_signed_tls diff --git a/examples/call/config.ru b/examples/call/config.ru index cb827477..1612e129 100644 --- a/examples/call/config.ru +++ b/examples/call/config.ru @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'trenni' +require "trenni" class Output < Struct.new(:stream) def <<(chunk) diff --git a/examples/cookies/config.ru b/examples/cookies/config.ru index 7fd4545f..fb3f2768 100755 --- a/examples/cookies/config.ru +++ b/examples/cookies/config.ru @@ -1,9 +1,9 @@ #!/usr/bin/env falcon --verbose serve -c # frozen_string_literal: true -require 'rack/request' +require "rack/request" -KEY = 'my cookie' +KEY = "my cookie" run do |env| request = Rack::Request.new(env) @@ -11,7 +11,7 @@ run do |env| puts "All Cookies: #{request.cookies}" headers = {} - Rack::Utils.set_cookie_header!(headers, KEY, 'bar') + Rack::Utils.set_cookie_header!(headers, KEY, "bar") [200, headers, ["Hello World!"]] end diff --git a/examples/csv/config.ru b/examples/csv/config.ru index ad453dbd..322f453d 100755 --- a/examples/csv/config.ru +++ b/examples/csv/config.ru @@ -5,7 +5,7 @@ class MyApp def initialize(app) @app = app - @words = File.readlines('/usr/share/dict/words', chomp: true).each_slice(3).to_a + @words = File.readlines("/usr/share/dict/words", chomp: true).each_slice(3).to_a end def call(env) diff --git a/examples/echo/config.ru b/examples/echo/config.ru index ff6a9519..7c961385 100644 --- a/examples/echo/config.ru +++ b/examples/echo/config.ru @@ -13,5 +13,5 @@ class EchoBody end run lambda{|env| - [200, [], EchoBody.new(env['rack.input'])] + [200, [], EchoBody.new(env["rack.input"])] } diff --git a/examples/google/falcon.rb b/examples/google/falcon.rb index a7c6fe14..1dd01077 100755 --- a/examples/google/falcon.rb +++ b/examples/google/falcon.rb @@ -9,9 +9,9 @@ supervisor proxy "google.localhost", :self_signed_tls do - url 'https://www.google.com' + url "https://www.google.com" end proxy "codeotaku.localhost", :self_signed_tls do - url 'https://www.codeotaku.com' + url "https://www.codeotaku.com" end diff --git a/examples/headers/config.ru b/examples/headers/config.ru index 8172e984..303c5ea6 100644 --- a/examples/headers/config.ru +++ b/examples/headers/config.ru @@ -6,7 +6,7 @@ require "cgi" run ->(env) { params = CGI.parse env["QUERY_STRING"] - header = params.fetch("xid", []).first || '' + header = params.fetch("xid", []).first || "" [200, {"xid" => "m" + header }, ["hello"]] } \ No newline at end of file diff --git a/examples/hello/falcon.rb b/examples/hello/falcon.rb index 0ef22c18..0168b72f 100755 --- a/examples/hello/falcon.rb +++ b/examples/hello/falcon.rb @@ -4,15 +4,15 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'falcon/environment/self_signed_tls' -require 'falcon/environment/rack' -require 'falcon/environment/supervisor' +require "falcon/environment/self_signed_tls" +require "falcon/environment/rack" +require "falcon/environment/supervisor" -service 'hello.localhost' do +service "hello.localhost" do include Falcon::Environment::SelfSignedTLS include Falcon::Environment::Rack - scheme 'http' + scheme "http" protocol {Async::HTTP::Protocol::HTTP} # endpoint do @@ -25,6 +25,6 @@ # report :supervisor end -service 'supervisor' do +service "supervisor" do include Falcon::Environment::Supervisor end diff --git a/examples/internet/config.ru b/examples/internet/config.ru index 8d9acfce..b84e959d 100644 --- a/examples/internet/config.ru +++ b/examples/internet/config.ru @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'async' -require 'async/http/internet' +require "async" +require "async/http/internet" # Experimental. -require 'kernel/sync' +require "kernel/sync" class Search def initialize(app) @@ -38,10 +38,10 @@ class Search # The only point of this is to invoke one of the above two methods. def call(env) - case env['PATH_INFO'] - when '/sync' + case env["PATH_INFO"] + when "/sync" self.sync - when '/async' + when "/async" self.async end diff --git a/examples/memory/config.ru b/examples/memory/config.ru index e5d6844f..a92020bb 100644 --- a/examples/memory/config.ru +++ b/examples/memory/config.ru @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'allocations' +require_relative "allocations" use Allocations diff --git a/examples/push/client.rb b/examples/push/client.rb index af08797c..e74d1bd9 100644 --- a/examples/push/client.rb +++ b/examples/push/client.rb @@ -4,9 +4,9 @@ # Released under the MIT License. # Copyright, 2019-2023, by Samuel Williams. -require 'async' -require 'async/http/endpoint' -require 'async/http/client' +require "async" +require "async/http/endpoint" +require "async/http/client" Async do endpoint = Async::HTTP::Endpoint.parse("https://localhost:9292") diff --git a/examples/push/config.ru b/examples/push/config.ru index 79ae3ae8..606eaaa9 100644 --- a/examples/push/config.ru +++ b/examples/push/config.ru @@ -7,8 +7,8 @@ class EarlyHints end def call(env) - path = env['PATH_INFO'] - early_hints = early_hints = env['rack.early_hints'] + path = env["PATH_INFO"] + early_hints = early_hints = env["rack.early_hints"] Console.logger.debug("path: #{path} #{early_hints}") @@ -23,6 +23,6 @@ end use EarlyHints -use Rack::Static, :urls => [""], :root => __dir__, :index => 'index.html' +use Rack::Static, :urls => [""], :root => __dir__, :index => "index.html" run lambda{|env| [404, [], ["Not Found"]]} diff --git a/examples/pushback/Gemfile b/examples/pushback/Gemfile index 8bce38cc..baf34053 100644 --- a/examples/pushback/Gemfile +++ b/examples/pushback/Gemfile @@ -4,6 +4,6 @@ # Copyright, 2024, by Peter Schrammel. # Copyright, 2024, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" gem "falcon"# frozen_string_literal: true diff --git a/examples/pushback/config.ru b/examples/pushback/config.ru index d410cd18..91b7dee9 100644 --- a/examples/pushback/config.ru +++ b/examples/pushback/config.ru @@ -2,7 +2,7 @@ # https://tmr08c.github.io/2020/05/concurrent-ruby-hello-async/ # -require 'async' +require "async" class Pool def initialize(size:, workers:) @@ -79,7 +79,7 @@ class Task end def work - step 'working' + step "working" sleep 5 @body.write "(#{Time.now}) Hello World #{Process.pid} #{@task}\n" ensure @@ -91,7 +91,7 @@ class Task end def wait_for_worker - step('waiting') + step("waiting") Fiber.scheduler.yield while @wait work # @fiber.yield @@ -99,18 +99,18 @@ class Task end def continue - step('continue') + step("continue") @wait = false end def finish - step('finish') + step("finish") @body.close print_timings end def pushback - step('finish') + step("finish") @body.close end @@ -126,7 +126,7 @@ end pool = Pool.new(size: 15, workers: 10) run do |env| - request = env['protocol.http.request'] + request = env["protocol.http.request"] path = request.path pool.push(path) # returns [code, {}, body] end diff --git a/examples/redis/config.ru b/examples/redis/config.ru index 44be1904..744470fb 100644 --- a/examples/redis/config.ru +++ b/examples/redis/config.ru @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'sinatra/base' -require 'async/redis' -require 'async/clock' +require "sinatra/base" +require "async/redis" +require "async/clock" CLIENT = Async::Redis::Client.new(Async::Redis.local_endpoint) diff --git a/examples/sequel/Gemfile b/examples/sequel/Gemfile index edbae14d..70f36b5a 100644 --- a/examples/sequel/Gemfile +++ b/examples/sequel/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" -gem 'falcon' -gem 'sequel' \ No newline at end of file +gem "falcon" +gem "sequel" \ No newline at end of file diff --git a/examples/sequel/config.ru b/examples/sequel/config.ru index 06e5f8f6..4ad74d70 100644 --- a/examples/sequel/config.ru +++ b/examples/sequel/config.ru @@ -1,10 +1,10 @@ # frozen_string_literal: true # config.ru -require 'sequel' +require "sequel" # Turn on single threaded mode Sequel.single_threaded = true -DB = Sequel.sqlite('data.sqlite3') +DB = Sequel.sqlite("data.sqlite3") run(proc{|env| [200, {}, [DB[:user].get(:name)]]}) \ No newline at end of file diff --git a/examples/server/standalone.rb b/examples/server/standalone.rb index 8cd452d7..95b4d1e0 100644 --- a/examples/server/standalone.rb +++ b/examples/server/standalone.rb @@ -4,11 +4,11 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require 'async' -require 'async/http/endpoint' -require 'async/websocket/adapters/rack' +require "async" +require "async/http/endpoint" +require "async/websocket/adapters/rack" -require 'falcon' +require "falcon" module WebSocketApp def self.call(env) @@ -21,7 +21,7 @@ def self.call(env) end Async do - websocket_endpoint = Async::HTTP::Endpoint.parse('http://127.0.0.1:3000') + websocket_endpoint = Async::HTTP::Endpoint.parse("http://127.0.0.1:3000") app = Falcon::Server.middleware(WebSocketApp) diff --git a/examples/sinatra/config.ru b/examples/sinatra/config.ru index d6cfd130..09edbd7a 100755 --- a/examples/sinatra/config.ru +++ b/examples/sinatra/config.ru @@ -4,10 +4,10 @@ # Save this as `config.ru`, make it executable and then run it (or run falcon serve by hand) # Middleware that responds to incoming requests: -require 'sinatra/base' +require "sinatra/base" class MyApp < Sinatra::Base get "/" do - response = Faraday.get 'http://sushi.com/nigiri/sake.json' + response = Faraday.get "http://sushi.com/nigiri/sake.json" end end diff --git a/examples/sleep/config.ru b/examples/sleep/config.ru index eda824ed..4bec7f05 100644 --- a/examples/sleep/config.ru +++ b/examples/sleep/config.ru @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'async' +require "async" run do body = Async::HTTP::Body::Writable.new diff --git a/examples/streaming/config.ru b/examples/streaming/config.ru index 2361034c..1af3d83e 100644 --- a/examples/streaming/config.ru +++ b/examples/streaming/config.ru @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'trenni/template' +require "trenni/template" TEMPLATE = Trenni::Template.load(<<~'HTML') 99 bottles of beer diff --git a/examples/streaming/gems.rb b/examples/streaming/gems.rb index efcbd83e..6177f4c2 100644 --- a/examples/streaming/gems.rb +++ b/examples/streaming/gems.rb @@ -5,7 +5,7 @@ source "https://rubygems.org" -gem 'trenni', '~> 3.14' -gem 'rack', '3.0.0' -gem 'falcon', path: '../../' +gem "trenni", "~> 3.14" +gem "rack", "3.0.0" +gem "falcon", path: "../../" # gem 'protocol-http', path: '../../../protocol-http' diff --git a/examples/streaming_upload/config.ru b/examples/streaming_upload/config.ru index e0882a2d..090df03c 100755 --- a/examples/streaming_upload/config.ru +++ b/examples/streaming_upload/config.ru @@ -2,8 +2,8 @@ # run with: falcon serve -n 1 -b http://localhost:9292 -require 'digest' -require 'securerandom' +require "digest" +require "securerandom" class BodyHandler attr_reader :time, :md5, :size, :uuid @@ -42,12 +42,12 @@ class BodyHandler end run lambda { |env| - request = env['protocol.http.request'] - handler = BodyHandler.new(env['rack.input'], env['CONTENT_LENGTH']) + request = env["protocol.http.request"] + handler = BodyHandler.new(env["rack.input"], env["CONTENT_LENGTH"]) Console.info(self, "#{env['REQUEST_METHOD']} #{handler.uuid}: #{request.path} #{env['CONTENT_LENGTH']}") - if env['REQUEST_METHOD'] == 'POST' - if request.headers['expect']&.include?('100-continue') + if env["REQUEST_METHOD"] == "POST" + if request.headers["expect"]&.include?("100-continue") request.write_interim_response(Protocol::HTTP::Response[100]) end diff --git a/examples/streaming_upload/falcon.rb b/examples/streaming_upload/falcon.rb index ce868850..43b26fa0 100644 --- a/examples/streaming_upload/falcon.rb +++ b/examples/streaming_upload/falcon.rb @@ -8,7 +8,7 @@ hostname = File.basename(__dir__) rack hostname do - endpoint Async::HTTP::Endpoint.parse('http://localhost:9292').with(protocol: Async::HTTP::Protocol::HTTP1) + endpoint Async::HTTP::Endpoint.parse("http://localhost:9292").with(protocol: Async::HTTP::Protocol::HTTP1) end supervisor diff --git a/examples/streaming_upload/gems.rb b/examples/streaming_upload/gems.rb index 354fcd0c..b522e561 100644 --- a/examples/streaming_upload/gems.rb +++ b/examples/streaming_upload/gems.rb @@ -4,6 +4,6 @@ # Copyright, 2024, by Peter Schrammel. # Copyright, 2024, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" gem "falcon" diff --git a/examples/trailer/config.ru b/examples/trailer/config.ru index fb4e6c4a..7646b45e 100644 --- a/examples/trailer/config.ru +++ b/examples/trailer/config.ru @@ -1,7 +1,7 @@ #!/usr/bin/env falcon --verbose serve -c # frozen_string_literal: true -require 'async' +require "async" class RequestLogger def initialize(app) diff --git a/examples/trailer/falcon.rb b/examples/trailer/falcon.rb index 4276b6d5..b3ec08c6 100644 --- a/examples/trailer/falcon.rb +++ b/examples/trailer/falcon.rb @@ -6,6 +6,6 @@ load :rack, :self_signed_tls, :supervisor -rack 'trailer.localhost', :self_signed_tls +rack "trailer.localhost", :self_signed_tls supervisor diff --git a/examples/websockets/config.ru b/examples/websockets/config.ru index 1cb2e662..444e1293 100644 --- a/examples/websockets/config.ru +++ b/examples/websockets/config.ru @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'async/websocket' -require 'async/websocket/adapters/rack' +require "async/websocket" +require "async/websocket/adapters/rack" class App def handle_normal_request(env) - [200, {'content-type' => 'text/plain'}, ["Hello World"]] + [200, {"content-type" => "text/plain"}, ["Hello World"]] end def call(env) diff --git a/examples/websockets/falcon.rb b/examples/websockets/falcon.rb index 71928ec8..9e9249c5 100755 --- a/examples/websockets/falcon.rb +++ b/examples/websockets/falcon.rb @@ -4,15 +4,15 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require 'falcon/environment/self_signed_tls' -require 'falcon/environment/rack' -require 'falcon/environment/supervisor' +require "falcon/environment/self_signed_tls" +require "falcon/environment/rack" +require "falcon/environment/supervisor" -service 'websockets.localhost' do +service "websockets.localhost" do include Falcon::Environment::SelfSignedTLS include Falcon::Environment::Rack end -service 'supervisor' do +service "supervisor" do include Falcon::Environment::Supervisor end diff --git a/fixtures/server_context.rb b/fixtures/server_context.rb index 0458f10d..342a5e63 100644 --- a/fixtures/server_context.rb +++ b/fixtures/server_context.rb @@ -3,11 +3,11 @@ # Released under the MIT License. # Copyright, 2023-2024, by Samuel Williams. -require 'sus/fixtures/async' +require "sus/fixtures/async" -require 'falcon/server' -require 'async/http/client' -require 'async/http/endpoint' +require "falcon/server" +require "async/http/client" +require "async/http/endpoint" module ServerContext include Sus::Fixtures::Async::ReactorContext @@ -17,7 +17,7 @@ def protocol end def url - 'http://localhost:0' + "http://localhost:0" end def bound_urls diff --git a/fixtures/temporary_directory_context.rb b/fixtures/temporary_directory_context.rb index 531995de..81a69af7 100644 --- a/fixtures/temporary_directory_context.rb +++ b/fixtures/temporary_directory_context.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require 'tmpdir' +require "tmpdir" module TemporaryDirectoryContext def around(&block) diff --git a/gems.rb b/gems.rb index 2967575e..45558ec9 100644 --- a/gems.rb +++ b/gems.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2017-2024, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" gemspec @@ -16,9 +16,11 @@ # gem "async-http-cache", path: "../async-http-cache" # gem "protocol-http", path: "../protocol-http" # gem "protocol-http1", path: "../protocol-http1" +# gem "protocol-http2", path: "../protocol-http2" # gem "utopia-project", path: "../utopia-project" # gem "protocol-rack", path: "../protocol-rack" # gem "async-service", path: "../async-service" +# gem "io-stream", path: "../io-stream" group :maintenance, optional: true do gem "bake-modernize" @@ -29,25 +31,25 @@ end group :development do - gem 'ruby-prof', platform: :mri - gem 'io-watch' + gem "ruby-prof", platform: :mri + gem "io-watch" end group :test do - gem 'sus' - gem 'covered' + gem "sus" + gem "covered" gem "decode" gem "rubocop" - gem 'sus-fixtures-async' - gem 'sus-fixtures-async-http' - gem 'sus-fixtures-openssl' + gem "sus-fixtures-async" + gem "sus-fixtures-async-http" + gem "sus-fixtures-openssl" gem "bake" - gem 'bake-test' - gem 'bake-test-external' + gem "bake-test" + gem "bake-test-external" - gem 'puma' + gem "puma" gem "rackup" gem "async-process" diff --git a/gems/async-head.rb b/gems/async-head.rb index 8a6d92fd..84af30b1 100644 --- a/gems/async-head.rb +++ b/gems/async-head.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2021-2023, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" eval_gemfile("../gems.rb") -gem 'async', git: "https://github.com/socketry/async" +gem "async", git: "https://github.com/socketry/async" diff --git a/gems/async-v1.rb b/gems/async-v1.rb index c876a971..0c5cec78 100644 --- a/gems/async-v1.rb +++ b/gems/async-v1.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2021-2023, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" eval_gemfile("../gems.rb") -gem 'async', '~> 1.0' +gem "async", "~> 1.0" diff --git a/gems/rack-head.rb b/gems/rack-head.rb index 4ecab32c..b9e407ef 100644 --- a/gems/rack-head.rb +++ b/gems/rack-head.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2019-2023, by Samuel Williams. -source 'https://rubygems.org' +source "https://rubygems.org" eval_gemfile("../gems.rb") -gem 'rack', github: 'rack/rack' +gem "rack", github: "rack/rack" diff --git a/lib/falcon/command.rb b/lib/falcon/command.rb index 7aca6da1..1d7ce1c0 100644 --- a/lib/falcon/command.rb +++ b/lib/falcon/command.rb @@ -4,7 +4,7 @@ # Copyright, 2017-2023, by Samuel Williams. # Copyright, 2018, by Mitsutaka Mimura. -require_relative 'command/top' +require_relative "command/top" module Falcon module Command diff --git a/lib/falcon/command/host.rb b/lib/falcon/command/host.rb index 41525d27..b8a5006d 100644 --- a/lib/falcon/command/host.rb +++ b/lib/falcon/command/host.rb @@ -3,11 +3,11 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require_relative 'paths' -require_relative '../version' +require_relative "paths" +require_relative "../version" -require 'samovar' -require 'async/service/controller' +require "samovar" +require "async/service/controller" module Falcon module Command diff --git a/lib/falcon/command/paths.rb b/lib/falcon/command/paths.rb index b43bf4e8..6e248921 100644 --- a/lib/falcon/command/paths.rb +++ b/lib/falcon/command/paths.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative '../configuration' +require_relative "../configuration" module Falcon module Command diff --git a/lib/falcon/command/proxy.rb b/lib/falcon/command/proxy.rb index 1189ef3c..15516d0b 100644 --- a/lib/falcon/command/proxy.rb +++ b/lib/falcon/command/proxy.rb @@ -3,10 +3,10 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative '../environment/proxy' -require_relative 'paths' +require_relative "../environment/proxy" +require_relative "paths" -require 'samovar' +require "samovar" module Falcon module Command @@ -19,9 +19,9 @@ class Proxy < Samovar::Command # The command line options. # @attribute [Samovar::Options] options do - option '--bind
', "Bind to the given hostname/address", default: "https://[::]:443" + option "--bind
", "Bind to the given hostname/address", default: "https://[::]:443" - option '-t/--timeout ', "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil + option "-t/--timeout ", "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil end # One or more paths to the configuration files. diff --git a/lib/falcon/command/redirect.rb b/lib/falcon/command/redirect.rb index 32c3ca6a..b46536cc 100644 --- a/lib/falcon/command/redirect.rb +++ b/lib/falcon/command/redirect.rb @@ -3,10 +3,10 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative '../environment/redirect' -require_relative 'paths' +require_relative "../environment/redirect" +require_relative "paths" -require 'samovar' +require "samovar" module Falcon module Command @@ -16,10 +16,10 @@ class Redirect < Samovar::Command # The command line options. # @attribute [Samovar::Options] options do - option '--bind
', "Bind to the given hostname/address", default: "http://[::]:80" - option '--redirect
', "Redirect using this address as a template.", default: "https://[::]:443" + option "--bind
", "Bind to the given hostname/address", default: "http://[::]:80" + option "--redirect
", "Redirect using this address as a template.", default: "https://[::]:443" - option '-t/--timeout ', "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil + option "-t/--timeout ", "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil end # One or more paths to the configuration files. diff --git a/lib/falcon/command/serve.rb b/lib/falcon/command/serve.rb index 78535591..86c949f4 100644 --- a/lib/falcon/command/serve.rb +++ b/lib/falcon/command/serve.rb @@ -4,15 +4,15 @@ # Copyright, 2018-2024, by Samuel Williams. # Copyright, 2018, by Mitsutaka Mimura. -require_relative '../server' -require_relative '../endpoint' -require_relative '../configuration' -require_relative '../service/server' -require_relative '../environment/rackup' +require_relative "../server" +require_relative "../endpoint" +require_relative "../configuration" +require_relative "../service/server" +require_relative "../environment/rackup" -require 'async/container' -require 'async/http/client' -require 'samovar' +require "async/container" +require "async/http/client" +require "samovar" module Falcon module Command @@ -25,26 +25,26 @@ class Serve < Samovar::Command # The command line options. # @attribute [Samovar::Options] options do - option '-b/--bind
', "Bind to the given hostname/address.", default: "https://localhost:9292" + option "-b/--bind
", "Bind to the given hostname/address.", default: "https://localhost:9292" - option '-p/--port ', "Override the specified port.", type: Integer - option '-h/--hostname ', "Specify the hostname which would be used for certificates, etc." - option '-t/--timeout ', "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil + option "-p/--port ", "Override the specified port.", type: Integer + option "-h/--hostname ", "Specify the hostname which would be used for certificates, etc." + option "-t/--timeout ", "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil - option '-c/--config ', "Rackup configuration file to load.", default: 'config.ru' - option '--preload ', "Preload the specified path before creating containers." + option "-c/--config ", "Rackup configuration file to load.", default: "config.ru" + option "--preload ", "Preload the specified path before creating containers." - option '--cache', "Enable the response cache." + option "--cache", "Enable the response cache." - option '--forked | --threaded | --hybrid', "Select a specific parallelism model.", key: :container, default: :forked + option "--forked | --threaded | --hybrid", "Select a specific parallelism model.", key: :container, default: :forked - option '-n/--count ', "Number of instances to start.", default: Async::Container.processor_count, type: Integer + option "-n/--count ", "Number of instances to start.", default: Async::Container.processor_count, type: Integer - option '--forks ', "Number of forks (hybrid only).", type: Integer - option '--threads ', "Number of threads (hybrid only).", type: Integer + option "--forks ", "Number of forks (hybrid only).", type: Integer + option "--threads ", "Number of threads (hybrid only).", type: Integer - option '--[no]-restart', "Enable/disable automatic restart.", default: true - option '--graceful-stop ', "Duration to wait for graceful stop.", type: Float, default: 1.0 + option "--[no]-restart", "Enable/disable automatic restart.", default: true + option "--graceful-stop ", "Duration to wait for graceful stop.", type: Float, default: 1.0 end def container_options diff --git a/lib/falcon/command/supervisor.rb b/lib/falcon/command/supervisor.rb index a1bb1082..99d69243 100644 --- a/lib/falcon/command/supervisor.rb +++ b/lib/falcon/command/supervisor.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'samovar' -require 'async' -require 'json' +require "samovar" +require "async" +require "json" -require 'io/endpoint/unix_endpoint' -require 'io/stream' +require "io/endpoint/unix_endpoint" +require "io/stream" module Falcon module Command @@ -30,7 +30,7 @@ class Restart < Samovar::Command # Send the restart message to the supervisor. def call(stream) - stream.puts({please: 'restart'}.to_json, separator: "\0") + stream.puts({please: "restart"}.to_json, separator: "\0") end end @@ -40,7 +40,7 @@ class Metrics < Samovar::Command # Send the metrics message to the supervisor and print the results. def call(stream) - stream.puts({please: 'metrics'}.to_json, separator: "\0", chomp: true) + stream.puts({please: "metrics"}.to_json, separator: "\0", chomp: true) response = JSON.parse(stream.read_until("\0"), symbolize_names: true) $stdout.puts response @@ -51,9 +51,9 @@ def call(stream) # @name nested # @attribute [Command] nested :command, { - 'restart' => Restart, - 'metrics' => Metrics, - }, default: 'metrics' + "restart" => Restart, + "metrics" => Metrics, + }, default: "metrics" # The endpoint the supervisor is bound to. def endpoint diff --git a/lib/falcon/command/top.rb b/lib/falcon/command/top.rb index c31b8606..6d7ae174 100644 --- a/lib/falcon/command/top.rb +++ b/lib/falcon/command/top.rb @@ -3,16 +3,16 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative 'serve' -require_relative 'host' -require_relative 'virtual' -require_relative 'proxy' -require_relative 'redirect' -require_relative 'supervisor' +require_relative "serve" +require_relative "host" +require_relative "virtual" +require_relative "proxy" +require_relative "redirect" +require_relative "supervisor" -require_relative '../version' +require_relative "../version" -require 'samovar' +require "samovar" module Falcon module Command @@ -23,23 +23,23 @@ class Top < Samovar::Command # The command line options. # @attribute [Samovar::Options] options do - option '--verbose | --quiet', "Verbosity of output for debugging.", key: :logging - option '-h/--help', "Print out help information." - option '-v/--version', "Print out the application version." - option '-e/--encoding', "Specify the default external encoding of the server.", default: "UTF-8" + option "--verbose | --quiet", "Verbosity of output for debugging.", key: :logging + option "-h/--help", "Print out help information." + option "-v/--version", "Print out the application version." + option "-e/--encoding", "Specify the default external encoding of the server.", default: "UTF-8" end # The nested command to execute. # @name nested # @attribute [Command] nested :command, { - 'serve' => Serve, - 'host' => Host, - 'virtual' => Virtual, - 'proxy' => Proxy, - 'redirect' => Redirect, - 'supervisor' => Supervisor, - }, default: 'serve' + "serve" => Serve, + "host" => Host, + "virtual" => Virtual, + "proxy" => Proxy, + "redirect" => Redirect, + "supervisor" => Supervisor, + }, default: "serve" # Whether verbose logging is enabled. # @returns [Boolean] diff --git a/lib/falcon/command/virtual.rb b/lib/falcon/command/virtual.rb index bf4e8ad9..ad078e92 100644 --- a/lib/falcon/command/virtual.rb +++ b/lib/falcon/command/virtual.rb @@ -3,11 +3,11 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'async/service' +require "async/service" -require_relative '../environment/virtual' +require_relative "../environment/virtual" -require 'samovar' +require "samovar" module Falcon module Command @@ -20,10 +20,10 @@ class Virtual < Samovar::Command # The command line options. # @attribute [Samovar::Options] options do - option '--bind-insecure
', "Bind redirection to the given hostname/address", default: "http://[::]:80" - option '--bind-secure
', "Bind proxy to the given hostname/address", default: "https://[::]:443" + option "--bind-insecure
", "Bind redirection to the given hostname/address", default: "http://[::]:80" + option "--bind-secure
", "Bind proxy to the given hostname/address", default: "https://[::]:443" - option '-t/--timeout ', "Specify the maximum time to wait for non-blocking operations.", type: Float, default: 30 + option "-t/--timeout ", "Specify the maximum time to wait for non-blocking operations.", type: Float, default: 30 end # One or more paths to the configuration files. diff --git a/lib/falcon/configuration.rb b/lib/falcon/configuration.rb index cbf324cc..07e5d1ff 100644 --- a/lib/falcon/configuration.rb +++ b/lib/falcon/configuration.rb @@ -4,7 +4,7 @@ # Copyright, 2019-2024, by Samuel Williams. # Copyright, 2019, by Sho Ito. -require 'async/service' +require "async/service" module Falcon # Manages environments which describes how to host a specific application. diff --git a/lib/falcon/endpoint.rb b/lib/falcon/endpoint.rb index f491dfa1..ef557b7c 100644 --- a/lib/falcon/endpoint.rb +++ b/lib/falcon/endpoint.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2018-2023, by Samuel Williams. -require 'async/http/endpoint' -require 'localhost/authority' +require "async/http/endpoint" +require "localhost/authority" module Falcon # An HTTP-specific endpoint which adds localhost TLS. diff --git a/lib/falcon/environment/application.rb b/lib/falcon/environment/application.rb index 3fad9586..6bea4041 100644 --- a/lib/falcon/environment/application.rb +++ b/lib/falcon/environment/application.rb @@ -4,8 +4,8 @@ # Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Daniel Evans. -require_relative 'server' -require_relative '../proxy_endpoint' +require_relative "server" +require_relative "../proxy_endpoint" module Falcon module Environment @@ -22,7 +22,7 @@ def middleware # The scheme to use to communicate with the application. # @returns [String] def scheme - 'https' + "https" end # The protocol to use to communicate with the application. diff --git a/lib/falcon/environment/lets_encrypt_tls.rb b/lib/falcon/environment/lets_encrypt_tls.rb index 15737a6b..8f5b16c3 100644 --- a/lib/falcon/environment/lets_encrypt_tls.rb +++ b/lib/falcon/environment/lets_encrypt_tls.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative 'tls' -require_relative '../environment' +require_relative "tls" +require_relative "../environment" module Falcon module Environment @@ -13,7 +13,7 @@ module LetsEncryptTLS # The Lets Encrypt certificate store path. # @parameter [String] def lets_encrypt_root - '/etc/letsencrypt/live' + "/etc/letsencrypt/live" end # The public certificate path. diff --git a/lib/falcon/environment/proxy.rb b/lib/falcon/environment/proxy.rb index a561f3f4..aa8072d4 100644 --- a/lib/falcon/environment/proxy.rb +++ b/lib/falcon/environment/proxy.rb @@ -3,10 +3,10 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative 'server' -require_relative '../tls' -require_relative '../middleware/proxy' -require_relative '../environment' +require_relative "server" +require_relative "../tls" +require_relative "../middleware/proxy" +require_relative "../environment" module Falcon module Environment @@ -43,7 +43,7 @@ def hosts Console.info(self) {"Proxying #{self.url} to #{evaluator.authority} using #{evaluator.endpoint}"} hosts[evaluator.authority] = evaluator - if RUBY_VERSION < '3.1' + if RUBY_VERSION < "3.1" # Ensure the SSL context is set up before forking - it's buggy on Ruby < 3.1: evaluator.ssl_context end diff --git a/lib/falcon/environment/rack.rb b/lib/falcon/environment/rack.rb index 63aae109..317a66a5 100644 --- a/lib/falcon/environment/rack.rb +++ b/lib/falcon/environment/rack.rb @@ -3,9 +3,9 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require_relative 'application' -require_relative 'rackup' -require_relative '../environment' +require_relative "application" +require_relative "rackup" +require_relative "../environment" module Falcon module Environment diff --git a/lib/falcon/environment/rackup.rb b/lib/falcon/environment/rackup.rb index 0a0ebe28..508c6ecc 100644 --- a/lib/falcon/environment/rackup.rb +++ b/lib/falcon/environment/rackup.rb @@ -3,15 +3,15 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require 'rack/builder' -require_relative '../server' +require "rack/builder" +require_relative "../server" module Falcon module Environment # Provides an environment for hosting loading a Rackup `config.ru` file. module Rackup def rackup_path - File.expand_path('config.ru', root) + File.expand_path("config.ru", root) end def rack_app diff --git a/lib/falcon/environment/redirect.rb b/lib/falcon/environment/redirect.rb index 4c431938..c5c5fd3f 100644 --- a/lib/falcon/environment/redirect.rb +++ b/lib/falcon/environment/redirect.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require_relative 'server' -require_relative '../middleware/redirect' +require_relative "server" +require_relative "../middleware/redirect" module Falcon module Environment diff --git a/lib/falcon/environment/self_signed_tls.rb b/lib/falcon/environment/self_signed_tls.rb index 8ba818a1..1c942d5a 100644 --- a/lib/falcon/environment/self_signed_tls.rb +++ b/lib/falcon/environment/self_signed_tls.rb @@ -3,9 +3,9 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'localhost/authority' -require_relative 'tls' -require_relative '../environment' +require "localhost/authority" +require_relative "tls" +require_relative "../environment" module Falcon module Environment diff --git a/lib/falcon/environment/server.rb b/lib/falcon/environment/server.rb index 11a6955b..d033c61b 100644 --- a/lib/falcon/environment/server.rb +++ b/lib/falcon/environment/server.rb @@ -3,11 +3,11 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require 'async/service/generic' -require 'async/http/endpoint' +require "async/service/generic" +require "async/http/endpoint" -require_relative '../service/server' -require_relative '../server' +require_relative "../service/server" +require_relative "../server" module Falcon module Environment diff --git a/lib/falcon/environment/supervisor.rb b/lib/falcon/environment/supervisor.rb index ac987ec8..caacfced 100644 --- a/lib/falcon/environment/supervisor.rb +++ b/lib/falcon/environment/supervisor.rb @@ -3,10 +3,10 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require_relative '../service/supervisor' -require_relative '../environment' +require_relative "../service/supervisor" +require_relative "../environment" -require 'io/endpoint/unix_endpoint' +require "io/endpoint/unix_endpoint" module Falcon module Environment diff --git a/lib/falcon/environment/tls.rb b/lib/falcon/environment/tls.rb index 4cfeeb77..0a3d9026 100644 --- a/lib/falcon/environment/tls.rb +++ b/lib/falcon/environment/tls.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require_relative '../tls' -require_relative '../environment' +require_relative "../tls" +require_relative "../environment" module Falcon module Environment diff --git a/lib/falcon/environment/virtual.rb b/lib/falcon/environment/virtual.rb index 5275afda..cc66ba92 100644 --- a/lib/falcon/environment/virtual.rb +++ b/lib/falcon/environment/virtual.rb @@ -3,9 +3,9 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require_relative 'configured' +require_relative "configured" -require_relative '../service/virtual' +require_relative "../service/virtual" module Falcon module Environment diff --git a/lib/falcon/middleware/proxy.rb b/lib/falcon/middleware/proxy.rb index 45e4af37..c8d81ffb 100644 --- a/lib/falcon/middleware/proxy.rb +++ b/lib/falcon/middleware/proxy.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'async/http/client' -require 'protocol/http/headers' -require 'protocol/http/middleware' +require "async/http/client" +require "protocol/http/headers" +require "protocol/http/middleware" -require 'console/event/failure' -require 'traces/provider' +require "console/event/failure" +require "traces/provider" module Falcon module Middleware @@ -25,21 +25,21 @@ def self.close # A HTTP middleware for proxying requests to a given set of hosts. # Typically used for implementing virtual servers. class Proxy < Protocol::HTTP::Middleware - FORWARDED = 'forwarded' - X_FORWARDED_FOR = 'x-forwarded-for' - X_FORWARDED_PROTO = 'x-forwarded-proto' + FORWARDED = "forwarded" + X_FORWARDED_FOR = "x-forwarded-for" + X_FORWARDED_PROTO = "x-forwarded-proto" - VIA = 'via' - CONNECTION = 'connection' + VIA = "via" + CONNECTION = "connection" # HTTP hop headers which *should* not be passed through the proxy. HOP_HEADERS = [ - 'connection', - 'keep-alive', - 'public', - 'proxy-authenticate', - 'transfer-encoding', - 'upgrade', + "connection", + "keep-alive", + "public", + "proxy-authenticate", + "transfer-encoding", + "upgrade", ] # Initialize the proxy middleware. @@ -78,7 +78,7 @@ def connect(endpoint) # @returns [Service::Proxy] def lookup(request) # Trailing dot and port is ignored/normalized. - if authority = request.authority&.sub(/(\.)?(:\d+)?$/, '') + if authority = request.authority&.sub(/(\.)?(:\d+)?$/, "") return @hosts[authority] end end @@ -119,7 +119,7 @@ def prepare_request(request, host) end unless forwarded.empty? - request.headers.add(FORWARDED, forwarded.join(';')) + request.headers.add(FORWARDED, forwarded.join(";")) end request.headers.add(VIA, "#{request.version} #{self.class}") @@ -145,7 +145,7 @@ def call(request) end rescue => error Console::Event::Failure.for(error).emit(self) - return Protocol::HTTP::Response[502, {'content-type' => 'text/plain'}, [error.class.name]] + return Protocol::HTTP::Response[502, {"content-type" => "text/plain"}, [error.class.name]] end Traces::Provider(self) do @@ -154,7 +154,7 @@ def call(request) "authority" => request.authority, } - Traces.trace('falcon.middleware.proxy.call', attributes: attributes) do + Traces.trace("falcon.middleware.proxy.call", attributes: attributes) do super end end diff --git a/lib/falcon/middleware/redirect.rb b/lib/falcon/middleware/redirect.rb index 24b8c019..0b89f1ee 100644 --- a/lib/falcon/middleware/redirect.rb +++ b/lib/falcon/middleware/redirect.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'async/http/client' +require "async/http/client" module Falcon module Middleware @@ -35,7 +35,7 @@ def initialize(app, hosts, endpoint) # @parameter request [Protocol::HTTP::Request] def lookup(request) # Trailing dot and port is ignored/normalized. - if authority = request.authority&.sub(/(\.)?(:\d+)?$/, '') + if authority = request.authority&.sub(/(\.)?(:\d+)?$/, "") return @hosts[authority] end end @@ -50,7 +50,7 @@ def call(request) location = "#{@endpoint.scheme}://#{host.authority}:#{@endpoint.port}#{request.path}" end - return Protocol::HTTP::Response[301, [['location', location]], []] + return Protocol::HTTP::Response[301, [["location", location]], []] else super end @@ -58,7 +58,7 @@ def call(request) Traces::Provider(self) do def call(request) - Traces.trace('falcon.middleware.redirect.call', attributes: {authority: request.authority}) do + Traces.trace("falcon.middleware.redirect.call", attributes: {authority: request.authority}) do super end end diff --git a/lib/falcon/middleware/verbose.rb b/lib/falcon/middleware/verbose.rb index c8ee5d75..cfea4639 100644 --- a/lib/falcon/middleware/verbose.rb +++ b/lib/falcon/middleware/verbose.rb @@ -3,8 +3,8 @@ # Released under the MIT License. # Copyright, 2018-2023, by Samuel Williams. -require 'console' -require 'async/http/statistics' +require "console" +require "async/http/statistics" module Falcon module Middleware diff --git a/lib/falcon/proxy_endpoint.rb b/lib/falcon/proxy_endpoint.rb index 74d09081..8254103a 100644 --- a/lib/falcon/proxy_endpoint.rb +++ b/lib/falcon/proxy_endpoint.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'io/endpoint/unix_endpoint' +require "io/endpoint/unix_endpoint" module Falcon # An endpoint suitable for proxing requests, typically via a unix pipe. diff --git a/lib/falcon/rackup/handler.rb b/lib/falcon/rackup/handler.rb index 66d09129..a6c1bf78 100644 --- a/lib/falcon/rackup/handler.rb +++ b/lib/falcon/rackup/handler.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require 'rackup/handler' +require "rackup/handler" -require_relative '../../falcon' +require_relative "../../falcon" -require 'kernel/sync' -require 'io/endpoint/host_endpoint' +require "kernel/sync" +require "io/endpoint/host_endpoint" module Falcon module Rackup @@ -25,7 +25,7 @@ def self.to_s # Generate an endpoint for the given `rackup` options. # @returns [::IO::Endpoint::HostEndpoint] def self.endpoint_for(**options) - host = options[:Host] || 'localhost' + host = options[:Host] || "localhost" port = Integer(options[:Port] || 9292) return ::IO::Endpoint.tcp(host, port) diff --git a/lib/falcon/server.rb b/lib/falcon/server.rb index 9ada434a..1d0190d3 100644 --- a/lib/falcon/server.rb +++ b/lib/falcon/server.rb @@ -3,15 +3,15 @@ # Released under the MIT License. # Copyright, 2017-2023, by Samuel Williams. -require 'async/http/server' +require "async/http/server" -require 'protocol/http/middleware/builder' -require 'protocol/http/content_encoding' +require "protocol/http/middleware/builder" +require "protocol/http/content_encoding" -require 'async/http/cache' +require "async/http/cache" -require_relative 'middleware/verbose' -require 'protocol/rack' +require_relative "middleware/verbose" +require "protocol/rack" module Falcon # A server listening on a specific endpoint, hosting a specific middleware. diff --git a/lib/falcon/service/server.rb b/lib/falcon/service/server.rb index 4dd9d0fc..22b969b7 100644 --- a/lib/falcon/service/server.rb +++ b/lib/falcon/service/server.rb @@ -4,10 +4,10 @@ # Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Daniel Evans. -require 'async/service/generic' -require 'async/http/endpoint' +require "async/service/generic" +require "async/http/endpoint" -require_relative '../server' +require_relative "../server" module Falcon module Service diff --git a/lib/falcon/service/supervisor.rb b/lib/falcon/service/supervisor.rb index 9e9ffde6..785474d0 100644 --- a/lib/falcon/service/supervisor.rb +++ b/lib/falcon/service/supervisor.rb @@ -3,13 +3,13 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'process/metrics' -require 'json' +require "process/metrics" +require "json" -require 'async/service/generic' +require "async/service/generic" -require 'io/endpoint/bound_endpoint' -require 'io/stream' +require "io/endpoint/bound_endpoint" +require "io/stream" module Falcon module Service @@ -50,9 +50,9 @@ def do_metrics(message) # @parameter message [Hash] The decoded message. def handle(message) case message[:please] - when 'restart' + when "restart" self.do_restart(message) - when 'metrics' + when "metrics" self.do_metrics(message) end end diff --git a/lib/falcon/service/virtual.rb b/lib/falcon/service/virtual.rb index b8ff2c96..f562b498 100644 --- a/lib/falcon/service/virtual.rb +++ b/lib/falcon/service/virtual.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2020-2024, by Samuel Williams. -require 'async/service/generic' +require "async/service/generic" module Falcon module Service @@ -18,14 +18,14 @@ class Virtual < Async::Service::Generic def assume_privileges(path) # Process.exec / Process.spawn don't replace the environment but instead update it, so we need to clear out any existing BUNDLE_ variables using `nil` values, which will cause them to be removed from the child environment: env = ENV.to_h do |key, value| - if key.start_with?('BUNDLE_') + if key.start_with?("BUNDLE_") [key, nil] else [key, value] end end - env['PWD'] = File.dirname(path) + env["PWD"] = File.dirname(path) stat = File.stat(path) @@ -33,7 +33,7 @@ def assume_privileges(path) Process::UID.change_privilege(stat.uid) home = Etc.getpwuid(stat.uid).dir - env['HOME'] = home + env["HOME"] = home return env end diff --git a/lib/rack/handler/falcon.rb b/lib/rack/handler/falcon.rb index 942c890d..3b319c7b 100644 --- a/lib/rack/handler/falcon.rb +++ b/lib/rack/handler/falcon.rb @@ -4,9 +4,9 @@ # Copyright, 2017-2024, by Samuel Williams. # Copyright, 2019, by Bryan Powell. -require 'rack/handler' +require "rack/handler" -require_relative '../../falcon/rackup/handler' +require_relative "../../falcon/rackup/handler" module Rack module Handler diff --git a/lib/rackup/handler/falcon.rb b/lib/rackup/handler/falcon.rb index 1fa2bdf6..9f3e73f0 100644 --- a/lib/rackup/handler/falcon.rb +++ b/lib/rackup/handler/falcon.rb @@ -3,9 +3,9 @@ # Released under the MIT License. # Copyright, 2023-2024, by Samuel Williams. -require 'rackup/handler' +require "rackup/handler" -require_relative '../../falcon/rackup/handler' +require_relative "../../falcon/rackup/handler" module Rackup module Handler diff --git a/test/falcon/command/config.ru b/test/falcon/command/config.ru index 5d84435e..cb143e01 100644 --- a/test/falcon/command/config.ru +++ b/test/falcon/command/config.ru @@ -1,4 +1,4 @@ # frozen_string_literal: true # This echos the body back. -run lambda { |env| [200, {}, env['rack.input'] || []] } +run lambda { |env| [200, {}, env["rack.input"] || []] } diff --git a/test/falcon/command/serve.rb b/test/falcon/command/serve.rb index ee96d3f1..fb4d4c14 100644 --- a/test/falcon/command/serve.rb +++ b/test/falcon/command/serve.rb @@ -4,7 +4,7 @@ # Copyright, 2018-2024, by Samuel Williams. # Copyright, 2019, by Sho Ito. -require 'falcon/command/serve' +require "falcon/command/serve" ServeCommand = Sus::Shared("falcon serve") do let(:command) do diff --git a/test/falcon/command/top.rb b/test/falcon/command/top.rb index c4fda880..012ed834 100644 --- a/test/falcon/command/top.rb +++ b/test/falcon/command/top.rb @@ -3,7 +3,7 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'falcon/command' +require "falcon/command" describe Falcon::Command::Top do with "basic server configuration" do diff --git a/test/falcon/command/virtual.rb b/test/falcon/command/virtual.rb index d768a761..f701d9ed 100644 --- a/test/falcon/command/virtual.rb +++ b/test/falcon/command/virtual.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'falcon/command/virtual' +require "falcon/command/virtual" -require 'async/http' -require 'protocol/http/request' +require "async/http" +require "protocol/http/request" -require 'async/websocket/client' +require "async/websocket/client" VirtualCommand = Sus::Shared("falcon virtual") do let(:paths) {[ @@ -45,7 +45,7 @@ def around let(:insecure_client) {Async::HTTP::Client.new(command.insecure_endpoint, retries: 0)} - with 'no paths' do + with "no paths" do let (:paths) {[]} it "should still start correctly" do @@ -66,7 +66,7 @@ def around response = insecure_client.call(request) expect(response).to be(:redirection?) - expect(response.headers['location']).to be == "https://hello.localhost:8443/index" + expect(response.headers["location"]).to be == "https://hello.localhost:8443/index" response.close end @@ -167,16 +167,16 @@ def around describe Falcon::Command::Virtual do with "HTTP/1.0" do let(:protocol) {Async::HTTP::Protocol::HTTP10} - it_behaves_like VirtualCommand, unique: 'HTTP10' + it_behaves_like VirtualCommand, unique: "HTTP10" end with "HTTP/1.1" do let(:protocol) {Async::HTTP::Protocol::HTTP11} - it_behaves_like VirtualCommand, unique: 'HTTP11' + it_behaves_like VirtualCommand, unique: "HTTP11" end with "HTTP/2" do let(:protocol) {Async::HTTP::Protocol::HTTP2} - it_behaves_like VirtualCommand, unique: 'HTTP2' + it_behaves_like VirtualCommand, unique: "HTTP2" end end diff --git a/test/falcon/configuration.rb b/test/falcon/configuration.rb index 2e04aab5..c7d96868 100644 --- a/test/falcon/configuration.rb +++ b/test/falcon/configuration.rb @@ -4,7 +4,7 @@ # Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Daniel Evans. -require 'falcon/configuration' +require "falcon/configuration" describe Falcon::Configuration do let(:configuration) {subject.new} diff --git a/test/falcon/middleware/proxy.rb b/test/falcon/middleware/proxy.rb index b2e29670..6c33cf0d 100644 --- a/test/falcon/middleware/proxy.rb +++ b/test/falcon/middleware/proxy.rb @@ -3,12 +3,12 @@ # Released under the MIT License. # Copyright, 2018-2024, by Samuel Williams. -require 'falcon/middleware/proxy' +require "falcon/middleware/proxy" -require 'sus/fixtures/async' -require 'async/http/client' -require 'async/http/endpoint' -require 'async/service/environment' +require "sus/fixtures/async" +require "async/http/client" +require "async/http/endpoint" +require "async/service/environment" describe Falcon::Middleware::Proxy do include Sus::Fixtures::Async::ReactorContext @@ -19,15 +19,15 @@ def proxy_for(**options) let(:proxy) do subject.new(Falcon::Middleware::BadRequest, { - 'www.google.com' => proxy_for(authority: "www.google.com", endpoint: Async::HTTP::Endpoint.parse('https://www.google.com')), - 'www.yahoo.com' => proxy_for(authority: "www.yahoo.com", endpoint: Async::HTTP::Endpoint.parse('https://www.yahoo.com')), + "www.google.com" => proxy_for(authority: "www.google.com", endpoint: Async::HTTP::Endpoint.parse("https://www.google.com")), + "www.yahoo.com" => proxy_for(authority: "www.yahoo.com", endpoint: Async::HTTP::Endpoint.parse("https://www.yahoo.com")), }) end - let(:headers) {Protocol::HTTP::Headers['accept' => '*/*']} + let(:headers) {Protocol::HTTP::Headers["accept" => "*/*"]} - it 'can select client based on authority' do - request = Protocol::HTTP::Request.new('https', 'www.google.com', 'GET', '/', nil, headers, nil) + it "can select client based on authority" do + request = Protocol::HTTP::Request.new("https", "www.google.com", "GET", "/", nil, headers, nil) expect(request).to receive(:remote_address).and_return(Addrinfo.ip("127.0.0.1")) @@ -36,13 +36,13 @@ def proxy_for(**options) expect(response).not.to be(:failure?) - expect(request.headers['x-forwarded-for']).to be == ["127.0.0.1"] + expect(request.headers["x-forwarded-for"]).to be == ["127.0.0.1"] proxy.close end - it 'defers if no host is available' do - request = Protocol::HTTP::Request.new('www.groogle.com', 'GET', '/', nil, headers, nil) + it "defers if no host is available" do + request = Protocol::HTTP::Request.new("www.groogle.com", "GET", "/", nil, headers, nil) response = proxy.call(request) response.finish diff --git a/test/falcon/rackup/handler/config.ru b/test/falcon/rackup/handler/config.ru index 2f8e7d03..41889868 100644 --- a/test/falcon/rackup/handler/config.ru +++ b/test/falcon/rackup/handler/config.ru @@ -1,4 +1,4 @@ # frozen_string_literal: true # This echos the body back. -run lambda { |env| [200, {}, [env['rack.input'].read]] } +run lambda { |env| [200, {}, [env["rack.input"].read]] } diff --git a/test/falcon/rackup/handler/falcon.rb b/test/falcon/rackup/handler/falcon.rb index 5f817d5e..36c01ede 100644 --- a/test/falcon/rackup/handler/falcon.rb +++ b/test/falcon/rackup/handler/falcon.rb @@ -3,14 +3,14 @@ # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. -require 'sus/fixtures/async' +require "sus/fixtures/async" -require 'falcon/server' -require 'async/http/endpoint' -require 'async/http/client' -require 'async/process' +require "falcon/server" +require "async/http/endpoint" +require "async/http/client" +require "async/process" -require 'rackup/handler/falcon' +require "rackup/handler/falcon" RackupHandler = Sus::Shared("rackup handler") do |server_name| include Sus::Fixtures::Async::ReactorContext @@ -49,7 +49,7 @@ end describe Falcon::Rackup::Handler do - it_behaves_like RackupHandler, 'falcon' + it_behaves_like RackupHandler, "falcon" let(:app) {lambda {|env| [200, {}, ["Hello World"]]}} diff --git a/test/falcon/server.rb b/test/falcon/server.rb index 91af578e..bae2506b 100644 --- a/test/falcon/server.rb +++ b/test/falcon/server.rb @@ -3,9 +3,9 @@ # Released under the MIT License. # Copyright, 2017-2024, by Samuel Williams. -require 'server_context' -require 'sus/fixtures/openssl/valid_certificate_context' -require 'sus/fixtures/openssl/verified_certificate_context' +require "server_context" +require "sus/fixtures/openssl/valid_certificate_context" +require "sus/fixtures/openssl/verified_certificate_context" describe Falcon::Server do include ServerContext @@ -45,14 +45,14 @@ end it "can POST application/x-www-form-urlencoded" do - response = client.post("/", {'content-type' => 'application/x-www-form-urlencoded'}, ['hello=world']) + response = client.post("/", {"content-type" => "application/x-www-form-urlencoded"}, ["hello=world"]) expect(response).to be(:success?) expect(response.read).to be =~ /POST: {"hello"\s?=>\s?"world"}/ end it "can POST multipart/form-data" do - response = client.post("/", {'content-type' => 'multipart/form-data; boundary=multipart'}, ["--multipart\r\n", "Content-Disposition: form-data; name=\"hello\"\r\n\r\n", "world\r\n", "--multipart--"]) + response = client.post("/", {"content-type" => "multipart/form-data; boundary=multipart"}, ["--multipart\r\n", "Content-Disposition: form-data; name=\"hello\"\r\n\r\n", "world\r\n", "--multipart--"]) expect(response).to be(:success?) expect(response.read).to be =~ /POST: {"hello"\s?=>\s?"world"}/ @@ -102,7 +102,7 @@ end end - with 'streaming response', timeout: nil do + with "streaming response", timeout: nil do let(:app) do lambda do |env| body = proc do |stream| diff --git a/test/falcon/service/server.rb b/test/falcon/service/server.rb index 21b06afc..3ac379aa 100644 --- a/test/falcon/service/server.rb +++ b/test/falcon/service/server.rb @@ -3,17 +3,17 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require 'falcon/service/server' -require 'falcon/configuration' -require 'falcon/environment/server' -require 'falcon/environment/rackup' +require "falcon/service/server" +require "falcon/configuration" +require "falcon/environment/server" +require "falcon/environment/rackup" describe Falcon::Service::Server do let(:environment) do Async::Service::Environment.new(Falcon::Environment::Server).with( Falcon::Environment::Rackup, - name: 'hello', - root: File.expand_path('.server/hello', __dir__), + name: "hello", + root: File.expand_path(".server/hello", __dir__), url: "http://localhost:0", ) end @@ -39,12 +39,12 @@ container.stop end - with 'a limited count' do + with "a limited count" do let(:environment) do Async::Service::Environment.new(Falcon::Environment::Server).with( Falcon::Environment::Rackup, - name: 'hello', - root: File.expand_path('.server/hello', __dir__), + name: "hello", + root: File.expand_path(".server/hello", __dir__), url: "http://localhost:0", count: 1, ) diff --git a/test/falcon/service/supervisor.rb b/test/falcon/service/supervisor.rb index 7e9cfb02..18c8d847 100644 --- a/test/falcon/service/supervisor.rb +++ b/test/falcon/service/supervisor.rb @@ -3,11 +3,11 @@ # Released under the MIT License. # Copyright, 2024, by Samuel Williams. -require 'falcon/service/supervisor' -require 'falcon/configuration' -require 'falcon/environment/supervisor' +require "falcon/service/supervisor" +require "falcon/configuration" +require "falcon/environment/supervisor" -require 'temporary_directory_context' +require "temporary_directory_context" describe Falcon::Service::Supervisor do include TemporaryDirectoryContext @@ -35,7 +35,7 @@ expect(container.group.running).to have_attributes(size: be == 1) - response = supervisor.invoke({please: 'metrics'}) + response = supervisor.invoke({please: "metrics"}) expect(response).to be_a(Hash) diff --git a/test/falcon/ssl_server.rb b/test/falcon/ssl_server.rb index 5ff6744f..2364836b 100644 --- a/test/falcon/ssl_server.rb +++ b/test/falcon/ssl_server.rb @@ -4,9 +4,9 @@ # Copyright, 2018-2024, by Samuel Williams. # Copyright, 2020, by Tasos Latsas. -require 'server_context' -require 'sus/fixtures/openssl/valid_certificate_context' -require 'sus/fixtures/openssl/verified_certificate_context' +require "server_context" +require "sus/fixtures/openssl/valid_certificate_context" +require "sus/fixtures/openssl/verified_certificate_context" describe Falcon::Server do with OpenSSL do