Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore WEBrick support #2067

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ gem 'redcarpet', platforms: [:ruby]
gem 'simplecov', require: false
gem 'slim', '~> 5'
gem 'yajl-ruby', platforms: [:ruby]
gem 'webrick'

# sass-embedded depends on google-protobuf
# which fails to be installed on JRuby and TruffleRuby under aarch64
Expand Down
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ class << self
set :running_server, nil
set :handler_name, nil
set :traps, true
set :server, %w[]
set :server, %w[webrick]
set :bind, proc { development? ? 'localhost' : '0.0.0.0' }
set :port, Integer(ENV['PORT'] && !ENV['PORT'].empty? ? ENV['PORT'] : 4567)
set :quiet, false
Expand Down
4 changes: 4 additions & 0 deletions test/integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def command
end
end

def webrick?
name.to_s == "webrick"
end

def puma?
name.to_s == "puma"
end
Expand Down
4 changes: 3 additions & 1 deletion test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class IntegrationTest < Minitest::Test
count = server.log.scan("GET /ping?x=#{random}").count
if server.net_http_server?
assert_equal 0, count
elsif server.webrick?
assert(count > 0)
else
assert_equal(1, count)
end
end

it 'streams' do
next if server.trinidad?
next if server.webrick? or server.trinidad?
times, chunks = [Process.clock_gettime(Process::CLOCK_MONOTONIC)], []
server.get_stream do |chunk|
next if chunk.empty?
Expand Down
5 changes: 5 additions & 0 deletions test/settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ def pub; end
end

describe 'server' do
it 'includes webrick' do
assert @base.server.include?('webrick')
assert @application.server.include?('webrick')
end

it 'includes puma' do
assert @base.server.include?('puma')
assert @application.server.include?('puma')
Expand Down