From 9f51dac2237857797435df405b00d7a8f396207d Mon Sep 17 00:00:00 2001 From: shugo Date: Wed, 7 Dec 2016 12:59:48 +0000 Subject: Delay Utils.getservername until needed. There is no need to call Utils.getservername when the :ServerName option is specified, so delay Utils.getservername until needed to avoid unnecessary DNS lookups. [ruby-core:78492] [Bug #13007] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/config.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb index 98c9701633..af4b561534 100644 --- a/lib/webrick/config.rb +++ b/lib/webrick/config.rb @@ -20,8 +20,14 @@ module WEBrick LIBDIR = File::dirname(__FILE__) # :nodoc: # for GenericServer - General = { - :ServerName => Utils::getservername, + General = Hash.new { |hash, key| + case key + when :ServerName + hash[key] = Utils.getservername + else + nil + end + }.update( :BindAddress => nil, # "0.0.0.0" or "::" or nil :Port => nil, # users MUST specify this!! :MaxClients => 100, # maximum number of the concurrent connections @@ -36,7 +42,7 @@ module WEBrick :AcceptCallback => nil, :DoNotReverseLookup => true, :ShutdownSocketWithoutClose => false, - } + ) # for HTTPServer, HTTPRequest, HTTPResponse ... HTTP = General.dup.update( -- cgit v1.2.3