Merge branch 'master' of https://github.com/channelcat/sanic
This commit is contained in:
commit
93e99c2821
|
@ -1,7 +1,7 @@
|
|||
# Extensions
|
||||
|
||||
A list of Sanic extensions created by the community.
|
||||
|
||||
- [Sanic-Plugins-Framework](https://github.com/ashleysommer/sanicpluginsframework): Library for easily creating and using Sanic plugins.
|
||||
- [Sessions](https://github.com/subyraman/sanic_session): Support for sessions.
|
||||
Allows using redis, memcache or an in memory store.
|
||||
- [CORS](https://github.com/ashleysommer/sanic-cors): A port of flask-cors.
|
||||
|
|
|
@ -312,7 +312,7 @@ class HttpProtocol(asyncio.Protocol):
|
|||
else:
|
||||
extra['byte'] = -1
|
||||
|
||||
if self.request:
|
||||
if self.request is not None:
|
||||
extra['host'] = '{0}:{1}'.format(self.request.ip[0],
|
||||
self.request.ip[1])
|
||||
extra['request'] = '{0} {1}'.format(self.request.method,
|
||||
|
|
|
@ -13,10 +13,18 @@ class WebSocketProtocol(HttpProtocol):
|
|||
self.websocket_max_size = websocket_max_size
|
||||
self.websocket_max_queue = websocket_max_queue
|
||||
|
||||
def connection_timeout(self):
|
||||
# timeouts make no sense for websocket routes
|
||||
def request_timeout_callback(self):
|
||||
if self.websocket is None:
|
||||
super().connection_timeout()
|
||||
super().request_timeout_callback()
|
||||
|
||||
def response_timeout_callback(self):
|
||||
if self.websocket is None:
|
||||
super().response_timeout_callback()
|
||||
|
||||
def keep_alive_timeout_callback(self):
|
||||
if self.websocket is None:
|
||||
super().keep_alive_timeout_callback()
|
||||
|
||||
def connection_lost(self, exc):
|
||||
if self.websocket is not None:
|
||||
|
|
|
@ -23,6 +23,9 @@ from sanic.websocket import WebSocketProtocol
|
|||
|
||||
class GunicornWorker(base.Worker):
|
||||
|
||||
http_protocol = HttpProtocol
|
||||
websocket_protocol = WebSocketProtocol
|
||||
|
||||
def __init__(self, *args, **kw): # pragma: no cover
|
||||
super().__init__(*args, **kw)
|
||||
cfg = self.cfg
|
||||
|
@ -46,8 +49,9 @@ class GunicornWorker(base.Worker):
|
|||
|
||||
def run(self):
|
||||
is_debug = self.log.loglevel == logging.DEBUG
|
||||
protocol = (WebSocketProtocol if self.app.callable.websocket_enabled
|
||||
else HttpProtocol)
|
||||
protocol = (
|
||||
self.websocket_protocol if self.app.callable.websocket_enabled
|
||||
else self.http_protocol)
|
||||
self._server_settings = self.app.callable._helper(
|
||||
loop=self.loop,
|
||||
debug=is_debug,
|
||||
|
|
Loading…
Reference in New Issue
Block a user