Support handler-encoding-ignorant embedders (#32)
Allow for embedders that don't provide the new handler_encoding option
inside the options object by using getattr() and falling back to None.
diff --git a/mod_pywebsocket/websocket_server.py b/mod_pywebsocket/websocket_server.py
index c9861bc..9f67c9f 100644
--- a/mod_pywebsocket/websocket_server.py
+++ b/mod_pywebsocket/websocket_server.py
@@ -85,11 +85,15 @@
if necessary.
"""
+ # Fall back to None for embedders that don't know about the
+ # handler_encoding option.
+ handler_encoding = getattr(options, "handler_encoding", None)
+
# Share a Dispatcher among request handlers to save time for
# instantiation. Dispatcher can be shared because it is thread-safe.
options.dispatcher = dispatch.Dispatcher(
options.websock_handlers, options.scan_dir,
- options.allow_handlers_outside_root_dir, options.handler_encoding)
+ options.allow_handlers_outside_root_dir, handler_encoding)
if options.websock_handlers_map_file:
_alias_handlers(options.dispatcher,
options.websock_handlers_map_file)