summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliris <liris.pp@gmail.com>2011-03-18 09:26:21 +0900
committerliris <liris.pp@gmail.com>2011-03-18 09:26:21 +0900
commit2537b77afaea899ca124b38db4dc4f75d2f7b98c (patch)
treed7ba0058f6dd9f77117d9eeb0f49642bbe0adc76
parentc1b30b0d9c2af2302506391e2303f0ccc90b9fa6 (diff)
downloadwebsocket-client-2537b77afaea899ca124b38db4dc4f75d2f7b98c.tar.gz
- add some doc string
-rw-r--r--websocket.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/websocket.py b/websocket.py
index a1adccd..b3194c2 100644
--- a/websocket.py
+++ b/websocket.py
@@ -104,6 +104,11 @@ def create_connection(url, timeout=None, **options):
Connect to url and return the WebSocket object.
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.
+
+ >>> conn = create_connection("ws://echo.websocket.org/",
+ ... headers={"User-Agent": "MyProgram"})
"""
websock = WebSocket()
websock.settimeout(timeout != None and timeout or default_timeout)
@@ -201,6 +206,12 @@ class WebSocket(object):
def connect(self, url, **options):
"""
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.
+
+ >>> ws = WebSocket()
+ >>> ws.connect("ws://echo.websocket.org/",
+ ... headers={"User-Agent": "MyProgram"})
"""
hostname, port, resource, is_secure = _parse_url(url)
# TODO: we need to support proxy