From 0787a2c2e014a4f93484539449bd90a0722045d6 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 16 Apr 2019 14:46:14 +0800 Subject: [PATCH] [Add]header support in WebsocketClient --- vnpy/api/websocket/websocket_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vnpy/api/websocket/websocket_client.py b/vnpy/api/websocket/websocket_client.py index 0fe28ee7..d2187276 100644 --- a/vnpy/api/websocket/websocket_client.py +++ b/vnpy/api/websocket/websocket_client.py @@ -49,18 +49,22 @@ class WebsocketClient(object): self.proxy_host = None self.proxy_port = None self.ping_interval = 60 # seconds + self.header = {} # For debugging self._last_sent_text = None self._last_received_text = None - def init(self, host: str, proxy_host: str = "", proxy_port: int = 0, ping_interval: int = 60): + def init(self, host: str, proxy_host: str = "", proxy_port: int = 0, ping_interval: int = 60, header: dict = None): """ :param ping_interval: unit: seconds, type: int """ self.host = host self.ping_interval = ping_interval # seconds + if header: + self.header = header + if proxy_host and proxy_port: self.proxy_host = proxy_host self.proxy_port = proxy_port @@ -139,6 +143,7 @@ class WebsocketClient(object): sslopt={"cert_reqs": ssl.CERT_NONE}, http_proxy_host=self.proxy_host, http_proxy_port=self.proxy_port, + header=self.header ) self.on_connected()