added dir resource, fixed body parsing issue

git-svn-id: file:///home/svn/incoming/trunk@3060 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-11-23 17:06:16 +00:00
parent 2f05b6959f
commit 2dc8cd66d3
2 changed files with 21 additions and 5 deletions

View File

@ -203,7 +203,9 @@ protected
idx = self.bufq.index(/\r*\n\r*\n/)
if (idx == -1)
self.headers.from_s(self.bufq)
self.headers.from_s(self.bufq)
else
idx += 4
end
if (idx >= 0)

View File

@ -123,9 +123,10 @@ class Server
# the resource is requested. The ``opts'' parameter can have any of the
# following:
#
# Proc (proc) - The procedure to call when a request comes in for this resource.
# LongCall (bool) - Hints to the server that this resource may have long
# request processing times.
# Proc (proc) - The procedure to call when a request comes in for this resource.
# LongCall (bool) - Hints to the server that this resource may have long
# request processing times.
# Directory (bool) - Whether or not this resource symbolizes a directory.
#
def add_resource(name, opts)
if (self.resources[name])
@ -198,8 +199,21 @@ protected
(request['Connection'].downcase == 'Keep-Alive'.downcase))
cli.keepalive = true
end
# If we fail to find the resource by full name, check if
# it's a directory resource
if ((p = self.resources[request.resource]) == nil)
resources.each_pair { |k, val|
if (val['Directory'] and request.resource =~ /^#{k}/)
p = val
break
end
}
end
if (p = self.resources[request.resource])
# If we found the resource handler for this resource, call its
# procedure.
if (p)
if (p['LongCall'] == true)
Thread.new {
p['Proc'].call(cli, request)