Commit 57af995f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Update README.rst

parent 911ffb24
...@@ -959,30 +959,28 @@ BaseRequestHandler usage: ...@@ -959,30 +959,28 @@ BaseRequestHandler usage:
#!/usr/bin/env python #!/usr/bin/env python
import io, ssl import io, ssl
from pprint import pprint
import nghttp2 import nghttp2
class Handler(nghttp2.BaseRequestHandler): class Handler(nghttp2.BaseRequestHandler):
def on_headers(self): def on_headers(self):
self.push(path='/css/bootstrap.css', self.push(path='/css/bootstrap.css',
request_headers = [(b'content-length', b'3')], request_headers = [('content-length', '3')],
status=200, status=200,
body='foo') body='foo')
self.push(path='/js/bootstrap.js', self.push(path='/js/bootstrap.js',
method='GET', method='GET',
request_headers = [(b'content-length', b'10')], request_headers = [('content-length', '10')],
status=200, status=200,
body='foobarbuzz') body='foobarbuzz')
self.send_response(status=200, self.send_response(status=200,
headers = [(b'content-type', b'text/plain')], headers = [('content-type', 'text/plain')],
body=io.BytesIO(b'nghttp2-python FTW')) body=io.BytesIO(b'nghttp2-python FTW'))
ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ctx.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 ctx.options = ssl.OP_ALL | ssl.OP_NO_SSLv2
ctx.set_npn_protocols(['h2-10'])
ctx.load_cert_chain('server.crt', 'server.key') ctx.load_cert_chain('server.crt', 'server.key')
# give None to ssl to make the server non-SSL/TLS # give None to ssl to make the server non-SSL/TLS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment