bug 640003 websockets - update incorporated pywebsockets to support -07 r=biesi
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009, Google Inc.
|
||||
# Copyright 2011, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -31,9 +31,10 @@
|
||||
"""PythonHeaderParserHandler for mod_pywebsocket.
|
||||
|
||||
Apache HTTP Server and mod_python must be configured such that this
|
||||
function is called to handle Web Socket request.
|
||||
function is called to handle WebSocket request.
|
||||
"""
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
from mod_python import apache
|
||||
@@ -57,7 +58,8 @@ _PYOPT_ALLOW_DRAFT75 = 'mod_pywebsocket.allow_draft75'
|
||||
|
||||
|
||||
class ApacheLogHandler(logging.Handler):
|
||||
"""Wrapper logging.Handler to emit log message to apache's error.log"""
|
||||
"""Wrapper logging.Handler to emit log message to apache's error.log."""
|
||||
|
||||
_LEVELS = {
|
||||
logging.DEBUG: apache.APLOG_DEBUG,
|
||||
logging.INFO: apache.APLOG_INFO,
|
||||
@@ -65,11 +67,12 @@ class ApacheLogHandler(logging.Handler):
|
||||
logging.ERROR: apache.APLOG_ERR,
|
||||
logging.CRITICAL: apache.APLOG_CRIT,
|
||||
}
|
||||
|
||||
def __init__(self, request=None):
|
||||
logging.Handler.__init__(self)
|
||||
self.log_error = apache.log_error
|
||||
if request is not None:
|
||||
self.log_error = request.log_error
|
||||
self.log_error = request.log_error
|
||||
|
||||
def emit(self, record):
|
||||
apache_level = apache.APLOG_DEBUG
|
||||
@@ -78,7 +81,7 @@ class ApacheLogHandler(logging.Handler):
|
||||
self.log_error(record.getMessage(), apache_level)
|
||||
|
||||
|
||||
logging.getLogger("mod_pywebsocket").addHandler(ApacheLogHandler())
|
||||
logging.getLogger('mod_pywebsocket').addHandler(ApacheLogHandler())
|
||||
|
||||
|
||||
def _create_dispatcher():
|
||||
@@ -111,12 +114,13 @@ def headerparserhandler(request):
|
||||
|
||||
try:
|
||||
allowDraft75 = apache.main_server.get_options().get(
|
||||
_PYOPT_ALLOW_DRAFT75, None)
|
||||
_PYOPT_ALLOW_DRAFT75, None)
|
||||
handshaker = handshake.Handshaker(request, _dispatcher,
|
||||
allowDraft75=allowDraft75)
|
||||
handshaker.do_handshake()
|
||||
request.log_error('mod_pywebsocket: resource: %r' % request.ws_resource,
|
||||
apache.APLOG_DEBUG)
|
||||
request.log_error(
|
||||
'mod_pywebsocket: resource: %r' % request.ws_resource,
|
||||
apache.APLOG_DEBUG)
|
||||
try:
|
||||
_dispatcher.transfer_data(request)
|
||||
except Exception, e:
|
||||
@@ -132,6 +136,8 @@ def headerparserhandler(request):
|
||||
except dispatch.DispatchError, e:
|
||||
request.log_error('mod_pywebsocket: %s' % e, apache.APLOG_WARNING)
|
||||
return apache.DECLINED
|
||||
# Set assbackwards to suppress response header generation by Apache.
|
||||
request.assbackwards = 1
|
||||
return apache.DONE # Return DONE such that no other handlers are invoked.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user