python: update README.rst

This commit is contained in:
Tatsuhiro Tsujikawa 2012-08-28 01:53:25 +09:00
parent fb6ef096c6
commit 5b521e608b
2 changed files with 58 additions and 0 deletions

View File

@ -82,3 +82,32 @@ Here is a simple SPDY server::
cert_file=CERT_FILE, cert_file=CERT_FILE,
key_file=KEY_FILE) key_file=KEY_FILE)
server.start() 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)

View File

@ -98,6 +98,35 @@ Here is a simple SPDY server::
cert_file=CERT_FILE, cert_file=CERT_FILE,
key_file=KEY_FILE) key_file=KEY_FILE)
server.start() 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 = [ classifiers = [
'Development Status :: 4 - Beta', 'Development Status :: 4 - Beta',