diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-08 09:52:34 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-09-08 09:52:34 +0000 |
commit | 7adf2333c9646cce73c4780c8edb08074446c827 (patch) | |
tree | a9c74524a00d0730e7252a1780284c9001dbd608 /lib/webrick | |
parent | 4d3a121e6eef0164f32a4042afca35caccef4c3b (diff) | |
download | ruby-7adf2333c9646cce73c4780c8edb08074446c827.tar.gz ruby-7adf2333c9646cce73c4780c8edb08074446c827.tar.xz ruby-7adf2333c9646cce73c4780c8edb08074446c827.zip |
* lib/webrick/accesslog.rb (AccessLog::setup_params): use req.port
instead of config[:Port] or req.request_uri.port.
* lib/webrick/httprequest.rb (HTTPRequest#meta_vars): ditto.
* lib/webrick/httpservlet/filehandler.rb (FileHandler#dir_list): ditto.
* lib/webrick/config.rb: :Listen option never be used.
* lib/webrick/server.rb (GenericServer#initialize): don't use :Listen
option and add warning message.
* lib/webrick/log.rb (BasicLog#<<): shortcut of log(INFO, ...).
* lib/webrick/httpserver.rb (HTTPServer#accesslog): use << for logging.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick')
-rw-r--r-- | lib/webrick/accesslog.rb | 2 | ||||
-rw-r--r-- | lib/webrick/config.rb | 1 | ||||
-rw-r--r-- | lib/webrick/httprequest.rb | 4 | ||||
-rw-r--r-- | lib/webrick/httpserver.rb | 8 | ||||
-rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 2 | ||||
-rw-r--r-- | lib/webrick/log.rb | 4 | ||||
-rw-r--r-- | lib/webrick/server.rb | 8 |
7 files changed, 15 insertions, 14 deletions
diff --git a/lib/webrick/accesslog.rb b/lib/webrick/accesslog.rb index 10a801196..25dcbc1be 100644 --- a/lib/webrick/accesslog.rb +++ b/lib/webrick/accesslog.rb @@ -33,7 +33,7 @@ module WEBrick params["l"] = "-" params["m"] = req.request_method params["o"] = res - params["p"] = config[:Port] + params["p"] = req.port params["q"] = req.query_string params["r"] = req.request_line.sub(/\x0d?\x0a\z/o, '') params["s"] = res.status # won't support "%>s" diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb index 229beada0..31c005336 100644 --- a/lib/webrick/config.rb +++ b/lib/webrick/config.rb @@ -23,7 +23,6 @@ module WEBrick :ServerName => Utils::getservername, :BindAddress => nil, # "0.0.0.0" or "::" or nil :Port => nil, # users MUST specifiy this!! - :Listen => [], # list of pairs of alt addr/port. :MaxClients => 100, # maximum number of the concurrent connections :ServerType => nil, # default: WEBrick::SimpleServer :Logger => nil, # default: WEBrick::Log.new diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb index 8b0803878..2b9f3f2f4 100644 --- a/lib/webrick/httprequest.rb +++ b/lib/webrick/httprequest.rb @@ -184,8 +184,8 @@ module WEBrick meta["REQUEST_METHOD"] = @request_method.dup meta["REQUEST_URI"] = @request_uri.to_s meta["SCRIPT_NAME"] = @script_name.dup - meta["SERVER_NAME"] = @request_uri.host - meta["SERVER_PORT"] = @config[:Port].to_s + meta["SERVER_NAME"] = @host + meta["SERVER_PORT"] = @port meta["SERVER_PROTOCOL"] = "HTTP/" + @config[:HTTPVersion].to_s meta["SERVER_SOFTWARE"] = @config[:ServerSoftware].dup diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb index a3da99db1..f50e7d52d 100644 --- a/lib/webrick/httpserver.rb +++ b/lib/webrick/httpserver.rb @@ -31,10 +31,9 @@ module WEBrick end unless @config[:AccessLog] - basic_log = BasicLog::new @config[:AccessLog] = [ - [ basic_log, AccessLog::COMMON_LOG_FORMAT ], - [ basic_log, AccessLog::REFERER_LOG_FORMAT ] + [ $stderr, AccessLog::COMMON_LOG_FORMAT ], + [ $stderr, AccessLog::REFERER_LOG_FORMAT ] ] end end @@ -123,9 +122,8 @@ module WEBrick def access_log(config, req, res) param = AccessLog::setup_params(config, req, res) - level = Log::INFO @config[:AccessLog].each{|logger, fmt| - logger.log(level, AccessLog::format(fmt, param)) + logger << AccessLog::format(fmt, param) } end diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index f6db991bf..9e1a439b1 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -318,7 +318,7 @@ module WEBrick res.body << <<-_end_of_html_ <ADDRESS> #{HTMLUtils::escape(@config[:ServerSoftware])}<BR> - at #{req.request_uri.host}:#{@config[:Port]} + at #{req.host}:#{req.port} </ADDRESS> </BODY> </HTML> diff --git a/lib/webrick/log.rb b/lib/webrick/log.rb index 2f5610273..9331020ab 100644 --- a/lib/webrick/log.rb +++ b/lib/webrick/log.rb @@ -40,6 +40,10 @@ module WEBrick end end + def <<(obj) + log(INFO, obj.to_s) + end + def fatal(msg) log(FATAL, "FATAL " << format(msg)); end def error(msg) log(ERROR, "ERROR " << format(msg)); end def warn(msg) log(WARN, "WARN " << format(msg)); end diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb index c71b11864..77519bf8e 100644 --- a/lib/webrick/server.rb +++ b/lib/webrick/server.rb @@ -56,11 +56,11 @@ module WEBrick @logger.info("ruby #{rubyv}") @listeners = [] - unless @config[:DoNotListen] + unless @config[:DoNotListen] + if @config[:Listen] + warn(":Listen option is deprecated; use GenericServer#listen") + end listen(@config[:BindAddress], @config[:Port]) - @config[:Listen].each{|addr, port| - listen(addr, port).each{|sock| @listeners << sock } - } end end |