Hi,
In message <D241B0E8-4ACF-11D9-B260-000A95CCCA58@3skel.com>,
`Dan Janowski <danj@3skel.com>' wrote:
> I have started using webrick and I like it a lot. In my application of
> using it, I made a few feature changes that I wanted to share.
Thanks. I'd like to merge some features.
> 1. make req.attributes available in the accesslog parser as 'n',
> similar to Apache notes. This seemed like a very good place to put
> application information that might be used for enhanced logging.
OK, I'll merge it.
> 2. Expose @logger in httpresponse so that any handler can log via the
> server.
CVS version of WEBrick supports virtual host and each server
may have different @logger object. However, the Log object
referred by res.logger isn't tied to a related server,
because it is determined before reading request. Thread
variables may be a solution of this.
> 3. Added a config :EncodingHandler which gets called after service() in
> the run method. This is a good place to employ content compression. I
> have written a basic deflate, gzip encoder that takes a body and
> compresses it on the fly. This seems to work very well. I need to make
> a few improvements to the encoder, then I will post it as well.
Agreed.
But I prefer more generic name than ":EncodingHandler", This
proc can do more than about content encoding. I think it
may be :ResponseCallback, PostProceessCallback, etc..
> 4. filehandler ignores files ending in ~ (emacs terd files). Using
> fnmatch with a single string value is deficient if there are multiple
> patterns to be ignored. A better way may be to check if
> NondisclosureName is an array, then evaluate the series, or to see if
> it is a Regexp object, then just apply that instead.
OK. I think NondisclosureName should be a Enumerable. The
following patch is a fix for HEAD of CVS.
--- lib/webrick/httpservlet/filehandler.rb 12 Oct 2004 12:26:39 -0000 1.5
+++ lib/webrick/httpservlet/filehandler.rb 12 Dec 2004 14:22:45 -0000
@@ -255,10 +255,12 @@ def set_filename(req, res)
end
def check_filename(name)
- if File.fnmatch("/#{@options[:NondisclosureName]}", name)
- @logger.warn("the request refers nondisclosure name `#{name}'.")
- raise HTTPStatus::NotFound, "`#{req.path}' not found."
- end
+ @options[:NondisclosureName].each{|pattern|
+ if File.fnmatch("/#{pattern}", name)
+ @logger.warn("the request refers nondisclosure name `#{name}'.")
+ raise HTTPStatus::NotFound, "`#{req.path}' not found."
+ end
+ }
end
--
gotoyuzo