:attr:`server_port`. The server is accessible by the handler, typically
through the handler's :attr:`server` instance variable.
+.. class:: ThreadedHTTPServer(server_address, RequestHandlerClass)
-The :class:`HTTPServer` must be given a *RequestHandlerClass* on instantiation,
-of which this module provides three different variants:
+ This class is identical to HTTPServer but uses threads to handle
+ requests by using the :class:`~socketserver.ThreadingMixin`. This
+ is usefull to handle web browsers pre-opening sockets, on which
+ :class:`HTTPServer` would wait indefinitly.
+
+The :class:`HTTPServer` and :class:`ThreadedHTTPServer` must be given
+a *RequestHandlerClass* on instantiation, of which this module
+provides three different variants:
.. class:: BaseHTTPRequestHandler(request, client_address, server)
__version__ = "0.6"
__all__ = [
- "HTTPServer", "BaseHTTPRequestHandler",
+ "HTTPServer", "ThreadedHTTPServer", "BaseHTTPRequestHandler",
"SimpleHTTPRequestHandler", "CGIHTTPRequestHandler",
]
self.server_port = port
+class ThreadedHTTPServer(socketserver.ThreadingMixIn, HTTPServer):
+ daemon_threads = True
+
+
class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
"""HTTP request handler base class.
def test(HandlerClass=BaseHTTPRequestHandler,
- ServerClass=HTTPServer, protocol="HTTP/1.0", port=8000, bind=""):
+ ServerClass=ThreadedHTTPServer,
+ protocol="HTTP/1.0", port=8000, bind=""):
"""Test the HTTP request handler class.
This runs an HTTP server on port 8000 (or the port argument).