From 8d7e430b89dbe5f01c7472306b92cce4cbc319bd Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 17 Nov 2016 13:57:46 +0100 Subject: [PATCH] Allow websocket connections from scripts scripts don't set origin on connection we allow these connections on API requests, websockets should match. --- notebook/base/zmqhandlers.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/notebook/base/zmqhandlers.py b/notebook/base/zmqhandlers.py index 0c942f5bf..7c04159b3 100644 --- a/notebook/base/zmqhandlers.py +++ b/notebook/base/zmqhandlers.py @@ -133,13 +133,9 @@ class WebSocketMixin(object): if origin is None: origin = self.get_origin() - # If no header is provided, assume we can't verify origin - if origin is None: - self.log.warning("Missing Origin header, rejecting WebSocket connection.") - return False - if host is None: - self.log.warning("Missing Host header, rejecting WebSocket connection.") - return False + # If no origin or host header is provided, assume from script + if origin is None or host is None: + return True origin = origin.lower() origin_host = urlparse(origin).netloc