[FIX] server: avoid werkzeug >= 2.1.1 connection close
Quick and dirty fix to avoid `'connection': 'close'` header with websocket. Part-of: odoo/odoo#112298
This commit is contained in:
committed by
Christophe Monniez
parent
9df3110cc7
commit
780cdf1e49
@@ -138,6 +138,14 @@ class RequestHandler(werkzeug.serving.WSGIRequestHandler):
|
||||
self.protocol_version = "HTTP/1.1"
|
||||
return environ
|
||||
|
||||
def send_header(self, keyword, value):
|
||||
# Prevent `WSGIRequestHandler` from sending the connection close header (compatibility with werkzeug >= 2.1.1 )
|
||||
# since it is incompatible with websocket.
|
||||
if self.headers.get('Upgrade') == 'websocket' and keyword == 'Connection' and value == 'close':
|
||||
# Do not keep processing requests.
|
||||
self.close_connection = True
|
||||
return
|
||||
super().send_header(keyword, value)
|
||||
|
||||
class ThreadedWSGIServerReloadable(LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer):
|
||||
""" werkzeug Threaded WSGI Server patched to allow reusing a listen socket
|
||||
|
||||
Reference in New Issue
Block a user