Name Description Size
client_https_setup_fragment.py Client HTTPS Setup ~~~~~~~~~~~~~~~~~~ This example code fragment demonstrates how to set up a HTTP/2 client that negotiates HTTP/2 using NPN and ALPN. For the sake of maximum explanatory value this code uses the synchronous, low-level sockets API: however, if you're not using sockets directly (e.g. because you're using asyncio), you should focus on the set up required for the SSLContext object. For other concurrency libraries you may need to use other setup (e.g. for Twisted you'll need to use IProtocolNegotiationFactory). This code requires Python 3.5 or later. 3887
client_upgrade_fragment.py Client Plaintext Upgrade ~~~~~~~~~~~~~~~~~~~~~~~~ This example code fragment demonstrates how to set up a HTTP/2 client that uses the plaintext HTTP Upgrade mechanism to negotiate HTTP/2 connectivity. For maximum explanatory value it uses the synchronous socket API that comes with the Python standard library. In product code you will want to use an actual HTTP/1.1 client if possible. This code requires Python 3.5 or later. 3726
server_https_setup_fragment.py Server HTTPS Setup ~~~~~~~~~~~~~~~~~~ This example code fragment demonstrates how to set up a HTTP/2 server that negotiates HTTP/2 using NPN and ALPN. For the sake of maximum explanatory value this code uses the synchronous, low-level sockets API: however, if you're not using sockets directly (e.g. because you're using asyncio), you should focus on the set up required for the SSLContext object. For other concurrency libraries you may need to use other setup (e.g. for Twisted you'll need to use IProtocolNegotiationFactory). This code requires Python 3.5 or later. 3875
server_upgrade_fragment.py Server Plaintext Upgrade ~~~~~~~~~~~~~~~~~~~~~~~~ This example code fragment demonstrates how to set up a HTTP/2 server that uses the plaintext HTTP Upgrade mechanism to negotiate HTTP/2 connectivity. For maximum explanatory value it uses the synchronous socket API that comes with the Python standard library. In product code you will want to use an actual HTTP/1.1 server library if possible. This code requires Python 3.5 or later. 3149