From 852cbe1e4d11cf58b91e8d72c1dfac82282db5c9 Mon Sep 17 00:00:00 2001 From: Phil Rene Date: Tue, 17 Apr 2012 23:16:32 -0400 Subject: [PATCH] Just changing comments so it represent what need to be used to properly set header on a WebSocket object. Instead of a dict of key/value, it has to be an array of string for the headers to be added using headers.extend(options["header"]) --- websocket.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/websocket.py b/websocket.py index c6cb217..a4bc993 100644 --- a/websocket.py +++ b/websocket.py @@ -142,10 +142,12 @@ def create_connection(url, timeout=None, **options): Passing optional timeout parameter will set the timeout on the socket. If no timeout is supplied, the global default timeout setting returned by getdefauttimeout() is used. You can customize using 'options'. - If you set "headers" dict object, you can set your own custom header. + If you set "header" dict object, you can set your own custom header. >>> conn = create_connection("ws://echo.websocket.org/", - ... headers={"User-Agent": "MyProgram"}) + ... header={"User-Agent: MyProgram", + ... "x-custom: header"}) + timeout: socket timeout time. This value is integer. if you set None for this value, it means "use default_timeout value" @@ -364,11 +366,12 @@ class WebSocket(object): """ Connect to url. url is websocket url scheme. ie. ws://host:port/resource You can customize using 'options'. - If you set "headers" dict object, you can set your own custom header. + If you set "header" dict object, you can set your own custom header. >>> ws = WebSocket() >>> ws.connect("ws://echo.websocket.org/", - ... headers={"User-Agent": "MyProgram"}) + ... header={"User-Agent: MyProgram", + ... "x-custom: header"}) timeout: socket timeout time. This value is integer. if you set None for this value,