SUMMARY: CONSTR | METHOD | DETAIL: CONSTR | METHOD |
Content handlers are specified as an arrayref of 2-tuples consisting of
[ regular expression string, content handler class name ]When a client HTTP request is received, each registered content handler's regular expression string is applied to the URI in the order in which the handler's are listed in the content handler map until a match is found, at which point the content handler class's
getContent()/putContent()/getHeader()
method is invoked.
If no regular expression matches the URI,
a HTTP 404 (NOT FOUND) error is returned to the client.
Application specific parameters for content handlers may be provided by creating a concrete implemention of the HTTP::Daemon::Threaded::ContentParams class, and supplying any constructor parameters as additional key/value pairs in the WebClient constructor hash.
Copyright© 2006, Dean Arnold, Presicient Corp., USA
All rights reserved.
Licensed under the Academic Free License version 2.1, as specified in the License.txt file included in this software package, or at OpenSource.org.
Unless otherwise noted, $self
is the object instance variable.
Constructor Summary |
---|
new(HTTPD => value, LogLevel => value, EventLogger => value, WebLogger => value, Handlers => value, ID => value, InactivityTimer => value, ContentParams => value, UserAuth => value, SessionCache => value, DocRoot => value, URL => value, ProductTokens => value, MediaTypes => value, FreeList => value, SelectInterval => value)
Creates an empty HTTP::Daemon::Threaded::Socket object |
Method Summary |
---|
acceptConnection($fn)
Accepts a web client connection |
freeClient($client)
Return a client to the free list |
get_simplex_methods()
Overrides Thread::Apartment::Server::get_simplex_methods() |
handleSocketEvent($fd)
Handles a socket event |
run()
Thread::Apartment::MuxServer::run() implementation |
Constructor Details |
---|
new(HTTPD => value, LogLevel => value, EventLogger => value, WebLogger => value, Handlers => value, ID => value, InactivityTimer => value, ContentParams => value, UserAuth => value, SessionCache => value, DocRoot => value, URL => value, ProductTokens => value, MediaTypes => value, FreeList => value, SelectInterval => value)
Note that the following parameters are recognized by HTTP::Daemon::Threaded::WebClient, but applications may supply additional parameter key/value pairs which will be provided to the constructor for any specified HTTP::Daemon::Threaded::ContentParams class.
HTTPD
=> the parent daemon object
LogLevel
=> (optional) logging level; 1 => errors only; 2 => errors and warnings only; 3 => errors, warnings,
and info messages; default 1
EventLogger
=> (optional) Instance of a HTTP::Daemon::Threaded::Logger to receive
event notifications (except for web requests)
WebLogger
=> (optional) Instance of a HTTP::Daemon::Threaded::Logger to receive
web request notifications
Handlers
=> arrayref mapping URL regex strings to handler classes
ID
=> unique client identifier
InactivityTimer
=> (optional) number of seconds to wait before disconnecting an idle connection
ContentParams
=> (optional) name of a ContentsParam concrete implementation
UserAuth
=> (optional) User authentication package name (not yet supported)
SessionCache
=> (optional) threads::shared object implementing HTTP::Daemon::Threaded::SessionCache
DocRoot
=> (optional) root directory for default file based content handler
URL
=> the base address/port of our listener
ProductTokens
=> product token string from listener
MediaTypes
=> (optional) hashref mapping 'Content-Type' specifications to
file qualifier strings. Values may be either a single string literal, or
an arrayref of string literals, e.g.,MediaTypes => { 'text/css' => 'css' }
. Used to
add media types for LWP::MediaTypes::guess_media_type()
FreeList
=> free client list; threads::shared array optimized to quickly
allocate/free WebClient objects
SelectInterval
=> seconds to wait in select()'s on sockets. May be fractional; default 0.5
Method Details |
---|
acceptConnection($fn)
$fn
- file number of the new socket
freeClient($client)
$client
- ID of the client being freed
get_simplex_methods()
handleSocketEvent($fd)
$fd
- the HTTP::Daemon::Threaded::Socket object on which the event occured
run()