summaryrefslogtreecommitdiff
path: root/eventlet/websocket.py
diff options
context:
space:
mode:
authorcatroot <andrey@ledovskikh.ru>2016-07-04 22:00:53 +0300
committerSergey Shepelev <temotor@gmail.com>2016-07-06 18:53:53 +0500
commit6de8d478ca2ee152e1c28d37b1c91b15a6717faf (patch)
tree56b7685892ce68cd40b81189d79d48a6d6d1d5ad /eventlet/websocket.py
parent863a1b7605b5c90ba470e597666c61a3261b706c (diff)
downloadeventlet-pull-331.tar.gz
websocket: support Gunicorn environ['gunicorn.socket']pull-331
Now you able to upgrade connection with eventlet.websocket.WebSocketsWSGI when app runs under `gunicorn application:app -k eventlet` https://github.com/eventlet/eventlet/pull/331
Diffstat (limited to 'eventlet/websocket.py')
-rw-r--r--eventlet/websocket.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/eventlet/websocket.py b/eventlet/websocket.py
index 9321956..1fdb3bf 100644
--- a/eventlet/websocket.py
+++ b/eventlet/websocket.py
@@ -135,7 +135,12 @@ class WebSocketWSGI(object):
return wsgi.ALREADY_HANDLED
def _handle_legacy_request(self, environ):
- sock = environ['eventlet.input'].get_socket()
+ if 'eventlet.input' in environ:
+ sock = environ['eventlet.input'].get_socket()
+ elif 'gunicorn.socket' in environ:
+ sock = environ['gunicorn.socket']
+ else:
+ raise Exception('No eventlet.input or gunicorn.socket present in environ.')
if 'HTTP_SEC_WEBSOCKET_KEY1' in environ:
self.protocol_version = 76
@@ -192,7 +197,13 @@ class WebSocketWSGI(object):
return WebSocket(sock, environ, self.protocol_version)
def _handle_hybi_request(self, environ):
- sock = environ['eventlet.input'].get_socket()
+ if 'eventlet.input' in environ:
+ sock = environ['eventlet.input'].get_socket()
+ elif 'gunicorn.socket' in environ:
+ sock = environ['gunicorn.socket']
+ else:
+ raise Exception('No eventlet.input or gunicorn.socket present in environ.')
+
hybi_version = environ['HTTP_SEC_WEBSOCKET_VERSION']
if hybi_version not in ('8', '13', ):
raise BadRequest(status='426 Upgrade Required',