diff options
author | Denis Bilenko <denis@ag-projects.com> | 2008-11-05 17:10:28 +0600 |
---|---|---|
committer | Denis Bilenko <denis@ag-projects.com> | 2008-11-05 17:10:28 +0600 |
commit | 3838c8f032b43ac9bb2cdba4eb058a4e4a4d997a (patch) | |
tree | 0fa7290ccf955b5b45d234d235961667aa2576c4 /examples | |
parent | 35d9abf7865f2b15684ed4a8794e94a218c212a0 (diff) | |
download | eventlet-3838c8f032b43ac9bb2cdba4eb058a4e4a4d997a.tar.gz |
added example for ssl and LineOnlyReceiver to twisted_basic_client.py
Diffstat (limited to 'examples')
-rw-r--r-- | examples/twisted_basic_client.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/twisted_basic_client.py b/examples/twisted_basic_client.py index 2781eda..b8f18e8 100644 --- a/examples/twisted_basic_client.py +++ b/examples/twisted_basic_client.py @@ -1,3 +1,5 @@ +from twisted.internet import ssl +from twisted.internet.error import ConnectionClosed from eventlet.twistedutil.protocol import BufferCreator from eventlet.twistedutil.protocols.basic import LineOnlyReceiverBuffer @@ -8,3 +10,12 @@ conn = BufferCreator(reactor).connectTCP('www.google.com', 80) conn.write('GET / HTTP/1.0\r\n\r\n') print conn.read() +# read from SSL connection line by line +conn = BufferCreator(reactor, LineOnlyReceiverBuffer).connectSSL('sf.net', 443, ssl.ClientContextFactory()) +conn.write('GET / HTTP/1.0\r\n\r\n') +try: + for num, line in enumerate(conn): + print '%3s %r' % (num, line) +except ConnectionClosed, ex: + print ex + |