mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
for reading request till data arrive. [ruby-talk:121068] * lib/webrick/server.rb (WEBrick::GenericServer#start_thread): should log about all accepted socket. [ruby-core:03962] * lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params): "%%" and "%u" are supported. [webricken:135] * lib/webrick/httpservlet/filehandler.rb (WEBrick::HTTPServlet::FileHandler#check_filename): :NondisclosureName is acceptable if it is Enumerable. * lib/webrick/config.rb (WEBrick::Config::FileHandler): default value of :NondisclosureName is [".ht*", "*~"]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d238fd1322
commit
1b492b7b28
6 changed files with 57 additions and 31 deletions
36
ChangeLog
36
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Thu Dec 16 18:44:58 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
|
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
|
||||||
|
for reading request till data arrive. [ruby-talk:121068]
|
||||||
|
|
||||||
|
* lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
|
||||||
|
should log about all accepted socket. [ruby-core:03962]
|
||||||
|
|
||||||
|
* lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
|
||||||
|
"%%" and "%u" are supported. [webricken:135]
|
||||||
|
|
||||||
|
* lib/webrick/httpservlet/filehandler.rb
|
||||||
|
(WEBrick::HTTPServlet::FileHandler#check_filename):
|
||||||
|
:NondisclosureName is acceptable if it is Enumerable.
|
||||||
|
|
||||||
|
* lib/webrick/config.rb (WEBrick::Config::FileHandler):
|
||||||
|
default value of :NondisclosureName is [".ht*", "*~"].
|
||||||
|
|
||||||
Thu Dec 16 18:36:52 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Thu Dec 16 18:36:52 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* ext/openssl/ossl.c (ossl_raise): refine message format.
|
* ext/openssl/ossl.c (ossl_raise): refine message format.
|
||||||
|
@ -48,24 +66,6 @@ Wed Dec 15 18:48:42 2004 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
* ext/curses/curses.c (window_subwin): call NUM2INT() before
|
* ext/curses/curses.c (window_subwin): call NUM2INT() before
|
||||||
GetWINDOW(). (backported from CVS HEAD)
|
GetWINDOW(). (backported from CVS HEAD)
|
||||||
|
|
||||||
Wed Dec 15 18:00:59 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
|
||||||
|
|
||||||
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
|
|
||||||
for reading request till data arrive. [ruby-talk:121068]
|
|
||||||
|
|
||||||
* lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
|
|
||||||
should log about all accepted socket. [ruby-core:03962]
|
|
||||||
|
|
||||||
* lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
|
|
||||||
"%%" and "%u" are supported. [webricken:135]
|
|
||||||
|
|
||||||
* lib/webrick/httpservlet/filehandler.rb
|
|
||||||
(WEBrick::HTTPServlet::FileHandler#check_filename):
|
|
||||||
:NondisclosureName is acceptable if it is Enumerable.
|
|
||||||
|
|
||||||
* lib/webrick/config.rb (WEBrick::Config::FileHandler):
|
|
||||||
default value of :NondisclosureName is [".ht*", "*~"].
|
|
||||||
|
|
||||||
Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
|
* win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
|
||||||
|
|
|
@ -32,6 +32,7 @@ module WEBrick
|
||||||
params["i"] = req
|
params["i"] = req
|
||||||
params["l"] = "-"
|
params["l"] = "-"
|
||||||
params["m"] = req.request_method
|
params["m"] = req.request_method
|
||||||
|
params["n"] = req.attributes
|
||||||
params["o"] = res
|
params["o"] = res
|
||||||
params["p"] = req.port
|
params["p"] = req.port
|
||||||
params["q"] = req.query_string
|
params["q"] = req.query_string
|
||||||
|
@ -46,15 +47,17 @@ module WEBrick
|
||||||
end
|
end
|
||||||
|
|
||||||
def format(format_string, params)
|
def format(format_string, params)
|
||||||
format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z])/){
|
format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){
|
||||||
param, spec = $1, $2
|
param, spec = $1, $2
|
||||||
case spec[0]
|
case spec[0]
|
||||||
when ?e, ?i, ?o
|
when ?e, ?i, ?n, ?o
|
||||||
raise AccessLogError,
|
raise AccessLogError,
|
||||||
"parameter is required for \"#{spec}\"" unless param
|
"parameter is required for \"#{spec}\"" unless param
|
||||||
params[spec][param] || "-"
|
params[spec][param] || "-"
|
||||||
when ?t
|
when ?t
|
||||||
params[spec].strftime(param || CLF_TIME_FORMAT)
|
params[spec].strftime(param || CLF_TIME_FORMAT)
|
||||||
|
when ?%
|
||||||
|
"%"
|
||||||
else
|
else
|
||||||
params[spec]
|
params[spec]
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,7 +65,7 @@ module WEBrick
|
||||||
)
|
)
|
||||||
|
|
||||||
FileHandler = {
|
FileHandler = {
|
||||||
:NondisclosureName => ".ht*",
|
:NondisclosureName => [".ht*", "*~"],
|
||||||
:FancyIndexing => false,
|
:FancyIndexing => false,
|
||||||
:HandlerTable => {},
|
:HandlerTable => {},
|
||||||
:HandlerCallback => nil,
|
:HandlerCallback => nil,
|
||||||
|
|
|
@ -46,6 +46,13 @@ module WEBrick
|
||||||
req = HTTPRequest.new(@config)
|
req = HTTPRequest.new(@config)
|
||||||
server = self
|
server = self
|
||||||
begin
|
begin
|
||||||
|
timeout = @config[:RequestTimeout]
|
||||||
|
while timeout > 0
|
||||||
|
break if IO.select([sock], nil, nil, 0.5)
|
||||||
|
timeout = 0 if @status != :Running
|
||||||
|
timeout -= 0.5
|
||||||
|
end
|
||||||
|
raise HTTPStatus::EOFError if timeout <= 0
|
||||||
req.parse(sock)
|
req.parse(sock)
|
||||||
res.request_method = req.request_method
|
res.request_method = req.request_method
|
||||||
res.request_uri = req.request_uri
|
res.request_uri = req.request_uri
|
||||||
|
|
|
@ -226,7 +226,7 @@ module WEBrick
|
||||||
|
|
||||||
path_info.unshift("") # dummy for checking @root dir
|
path_info.unshift("") # dummy for checking @root dir
|
||||||
while base = path_info.first
|
while base = path_info.first
|
||||||
check_filename(base)
|
check_filename(req, res, base)
|
||||||
break if base == "/"
|
break if base == "/"
|
||||||
break unless File.directory?(res.filename + base)
|
break unless File.directory?(res.filename + base)
|
||||||
shift_path_info(req, res, path_info)
|
shift_path_info(req, res, path_info)
|
||||||
|
@ -234,7 +234,7 @@ module WEBrick
|
||||||
end
|
end
|
||||||
|
|
||||||
if base = path_info.first
|
if base = path_info.first
|
||||||
check_filename(base)
|
check_filename(req, res, base)
|
||||||
if base == "/"
|
if base == "/"
|
||||||
if file = search_index_file(req, res)
|
if file = search_index_file(req, res)
|
||||||
shift_path_info(req, res, path_info, file)
|
shift_path_info(req, res, path_info, file)
|
||||||
|
@ -254,11 +254,13 @@ module WEBrick
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_filename(name)
|
def check_filename(req, res, name)
|
||||||
if File.fnmatch("/#{@options[:NondisclosureName]}", name)
|
@options[:NondisclosureName].each{|pattern|
|
||||||
@logger.warn("the request refers nondisclosure name `#{name}'.")
|
if File.fnmatch("/#{pattern}", name)
|
||||||
raise HTTPStatus::NotFound, "`#{req.path}' not found."
|
@logger.warn("the request refers nondisclosure name `#{name}'.")
|
||||||
end
|
raise HTTPStatus::NotFound, "`#{req.path}' not found."
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift_path_info(req, res, path_info, base=nil)
|
def shift_path_info(req, res, path_info, base=nil)
|
||||||
|
@ -306,6 +308,15 @@ module WEBrick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nondisclosure_name?(name)
|
||||||
|
@options[:NondisclosureName].each{|pattern|
|
||||||
|
if File.fnmatch(pattern, name)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def set_dir_list(req, res)
|
def set_dir_list(req, res)
|
||||||
redirect_to_directory_uri(req, res)
|
redirect_to_directory_uri(req, res)
|
||||||
unless @options[:FancyIndexing]
|
unless @options[:FancyIndexing]
|
||||||
|
@ -314,7 +325,7 @@ module WEBrick
|
||||||
local_path = res.filename
|
local_path = res.filename
|
||||||
list = Dir::entries(local_path).collect{|name|
|
list = Dir::entries(local_path).collect{|name|
|
||||||
next if name == "." || name == ".."
|
next if name == "." || name == ".."
|
||||||
next if File::fnmatch(@options[:NondisclosureName], name)
|
next if nondisclosure_name?(name)
|
||||||
st = (File::stat(local_path + name) rescue nil)
|
st = (File::stat(local_path + name) rescue nil)
|
||||||
if st.nil?
|
if st.nil?
|
||||||
[ name, nil, -1 ]
|
[ name, nil, -1 ]
|
||||||
|
|
|
@ -144,8 +144,13 @@ module WEBrick
|
||||||
Thread.start{
|
Thread.start{
|
||||||
begin
|
begin
|
||||||
Thread.current[:WEBrickSocket] = sock
|
Thread.current[:WEBrickSocket] = sock
|
||||||
addr = sock.peeraddr
|
begin
|
||||||
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
|
addr = sock.peeraddr
|
||||||
|
@logger.debug "accept: #{addr[3]}:#{addr[1]}"
|
||||||
|
rescue SocketError
|
||||||
|
@logger.debug "accept: <address unknown>"
|
||||||
|
raise
|
||||||
|
end
|
||||||
call_callback(:AcceptCallback, sock)
|
call_callback(:AcceptCallback, sock)
|
||||||
block ? block.call(sock) : run(sock)
|
block ? block.call(sock) : run(sock)
|
||||||
rescue Errno::ENOTCONN
|
rescue Errno::ENOTCONN
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue