This gist contains a really stupid implementation of a Twisted HTTP/2 client. It opens a connection, uses ALPN/NPN to negotiate HTTP/2, and then sends a single HTTP/2 GET request to the /ip
endpoint.
To execute this:
- Create a clean virtual environment.
- Install the requirements:
pip install -r requirements.txt
. - Install the development version of Twisted that contains the
nextProtocols
code. - Execute the code using
python h2test.py
.
If everything has gone correctly, you should see output that looks like this:
Received settings frame
Received headers: [(u':status', u'200'), (u'server', u'h2o/1.1.1'), (u'date', u'Mon, 01 Jun 2015 13:38:28 GMT'), (u'content-type', u'application/json'), (u'access-control-allow-origin', u'*'), (u'access-control-allow-credentials', u'true'), (u'x-clacks-overhead', u'GNU Terry Pratchett')]
Received data: {
"origin": "85.255.232.146"
}