summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-07 16:06:43 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-07 16:06:43 +0000
commit9b11fc8032b14fabacae74f77fbf02e1a3107eca (patch)
treee7e9e1ff2563012300e497e6328038f40ccdf65f
parent4774e8fda58ec97cff435da6cdb13a3f0b377e56 (diff)
* lib/webrick/config.rb (WEBrick::Config::HTTP): rename :RequestHander
to :RequestCallback and add new option :ServerAlias. * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): use :RequestCallback and warn if :RequestHandler is in server's option. * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should print error message for WEBrick::HTTPSataus::Error. * lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server): lookup for hostname from :ServerAlias if the req.host is not match to :ServerName. * lib/webrick/httpservlet.rb (WEBrick::HTTPServlet::CGIHandler#do_GET): use $?.exitstatus and refine log message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog18
-rw-r--r--lib/webrick/config.rb6
-rw-r--r--lib/webrick/httpserver.rb18
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb4
4 files changed, 35 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f67ba45fe..961ebc48b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Mon Mar 8 01:05:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/config.rb (WEBrick::Config::HTTP): rename :RequestHander
+ to :RequestCallback and add new option :ServerAlias.
+
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): use
+ :RequestCallback and warn if :RequestHandler is in server's option.
+
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should print
+ error message for WEBrick::HTTPSataus::Error.
+
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server):
+ lookup for hostname from :ServerAlias if the req.host is not match
+ to :ServerName.
+
+ * lib/webrick/httpservlet.rb (WEBrick::HTTPServlet::CGIHandler#do_GET):
+ use $?.exitstatus and refine log message.
+
Sun Mar 7 16:22:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* Makefile.in (lex.c): use $? instead of $<.
diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb
index 31c0053363..11e1966f13 100644
--- a/lib/webrick/config.rb
+++ b/lib/webrick/config.rb
@@ -45,14 +45,14 @@ module WEBrick
:DirectoryIndex => ["index.html","index.htm","index.cgi","index.rhtml"],
:DocumentRoot => nil,
:DocumentRootOptions => { :FancyIndexing => true },
+ :RequestCallback => nil,
+ :ServerAlias => nil,
- :RequestHandler => nil,
+ # for HTTPProxyServer
:ProxyAuthProc => nil,
:ProxyContentHandler => nil,
:ProxyVia => true,
:ProxyTimeout => true,
-
- # upstream proxy server
:ProxyURI => nil,
:CGIInterpreter => nil,
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb
index 7851ebe201..849706eb46 100644
--- a/lib/webrick/httpserver.rb
+++ b/lib/webrick/httpserver.rb
@@ -52,13 +52,18 @@ module WEBrick
res.request_http_version = req.http_version
res.keep_alive = req.keep_alive?
server = lookup_server(req) || self
- if handler = server[:RequestHandler]
- handler.call(req, res)
+ if callback = server[:RequestCallback]
+ callback.call(req, res)
+ elsif callback = server[:RequestHandler]
+ msg = ":RequestHandler is deprecated, please use :RequestCallback"
+ @logger.warn(msg)
+ callback.call(req, res)
end
server.service(req, res)
rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
res.set_error(ex)
rescue HTTPStatus::Error => ex
+ @logger.error(ex.message)
res.set_error(ex)
rescue HTTPStatus::Status => ex
res.status = ex.code
@@ -130,10 +135,11 @@ module WEBrick
end
def lookup_server(req)
- @virtual_hosts.find{|server|
- (server[:Port].nil? || req.port == server[:Port]) &&
- (server[:BindAddress].nil? || req.addr[3] == server[:BindAddress]) &&
- (server[:ServerName].nil? || req.host == server[:ServerName])
+ @virtual_hosts.find{|s|
+ (s[:Port].nil? || req.port == s[:Port]) &&
+ (s[:BindAddress].nil? || req.addr[3] == s[:BindAddress]) &&
+ ((s[:ServerName].nil? || req.host == s[:ServerName]) ||
+ (s[:ServerAlias].nil? || s[:ServerAlias].find{|h| h === req.host}))
}
end
diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb
index aa92bb4a2c..36f5e44ead 100644
--- a/lib/webrick/httpservlet/cgihandler.rb
+++ b/lib/webrick/httpservlet/cgihandler.rb
@@ -55,7 +55,7 @@ module WEBrick
end
ensure
cgi_in.close
- status = $? >> 8
+ status = $?.exitstatus
sleep 0.1 if /mswin/ =~ RUBY_PLATFORM
data = cgi_out.read
cgi_out.close(true)
@@ -74,7 +74,7 @@ module WEBrick
data = "" unless data
raw_header, body = data.split(/^[\xd\xa]+/on, 2)
raise HTTPStatus::InternalServerError,
- "The server encontered a script error." if body.nil?
+ "Premature end of script headers: #{@script_filename}" if body.nil?
begin
header = HTTPUtils::parse_header(raw_header)