Python 7.0pl5 Benutzerhandbuch

Seite von 124
Servlet Framework
94
becomes congested. Although the servlet may be forced to wait before it can send more data, any other
jobs in the event system will still be serviced, including other HTTP requests.
Logging of Requests
By default no information is logged about requests. If you wish to log what requests are being made
against your application using the HTTP servlet framework, you need to set the environment variable
"
OTCLIB_HTTPLOGCHANNEL
" to the name of the log channel to record the information on. The en-
vironment variable needs to be set prior to the first request being received by the application through
any instance of the
HttpDaemon
class.
dispatcher = netsvc.Dispatcher()
dispatcher.monitor(signal.SIGINT)
netsvc.mergeEnviron("OTCLIB_HTTPLOGCHANNEL","")
daemon = netsvc.HttpDaemon(8000)
filesrvr = netsvc.FileServer(os.getcwd())
daemon.attach("/",filesrvr)
daemon.start()
dispatcher.run()
The format of the logged messages is the same as Apache web server common log file format except
that no matter what version of HTTP is used, the url component of the request is always expanded to
its complete form. That is, it will be prefixed with "
http://hostname:port
" as appropriate. Nor-
mally this would only be the case if the request originated with a client supporting HTTP/1.1 protocol
and a full url had been supplied by the client.
If you do not want information about requests appearing in the default log file, but want to split out the
logged messages into a distinct log file, or otherwise treat them in a special way, use a hidden log chan-
nel and create a user defined log channel to capture them.