From 5b521e608b6969bfeff7c92a7504a7a018327034 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 28 Aug 2012 01:53:25 +0900 Subject: [PATCH] python: update README.rst --- python/README.rst | 29 +++++++++++++++++++++++++++++ python/setup.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/python/README.rst b/python/README.rst index 071de2a1..70772313 100644 --- a/python/README.rst +++ b/python/README.rst @@ -82,3 +82,32 @@ Here is a simple SPDY server:: cert_file=CERT_FILE, key_file=KEY_FILE) server.start() + +Here is a simple SPDY client:: + + #!/usr/bin/env python + + # The example SPDY client. You need Python 3.3 or later because we + # use TLS NPN. + # + # Usage: spdyclient.py URL... + # + import sys + import spdylay + + class MyStreamHandler(spdylay.BaseSPDYStreamHandler): + def on_header(self, nv): + sys.stdout.write('Stream#{}\n'.format(self.stream_id)) + for k, v in nv: + sys.stdout.write('{}: {}\n'.format(k, v)) + + def on_data(self, data): + sys.stdout.write('Stream#{}\n'.format(self.stream_id)) + sys.stdout.buffer.write(data) + + def on_close(self, status_code): + sys.stdout.write('Stream#{} closed\n'.format(self.stream_id)) + + if __name__ == '__main__': + uris = sys.argv[1:] + spdylay.urlfetch(uris, MyStreamHandler) diff --git a/python/setup.py b/python/setup.py index 82eda304..3d8f4f4c 100644 --- a/python/setup.py +++ b/python/setup.py @@ -98,6 +98,35 @@ Here is a simple SPDY server:: cert_file=CERT_FILE, key_file=KEY_FILE) server.start() + +Here is a simple SPDY client:: + + #!/usr/bin/env python + + # The example SPDY client. You need Python 3.3 or later because we + # use TLS NPN. + # + # Usage: spdyclient.py URL... + # + import sys + import spdylay + + class MyStreamHandler(spdylay.BaseSPDYStreamHandler): + def on_header(self, nv): + sys.stdout.write('Stream#{}\n'.format(self.stream_id)) + for k, v in nv: + sys.stdout.write('{}: {}\n'.format(k, v)) + + def on_data(self, data): + sys.stdout.write('Stream#{}\n'.format(self.stream_id)) + sys.stdout.buffer.write(data) + + def on_close(self, status_code): + sys.stdout.write('Stream#{} closed\n'.format(self.stream_id)) + + if __name__ == '__main__': + uris = sys.argv[1:] + spdylay.urlfetch(uris, MyStreamHandler) """, classifiers = [ 'Development Status :: 4 - Beta',