Asking for HTTP/2 Stwitching Protocols in python 3
<p>I'm trying to check if a http service supports HTTP/2 using a python 3 script.
Unfortunately, after many research and a lot of time spent on my script, I don't perform it.</p>

<p>Here what I have:</p>

<pre><code>import sys
import http.client as HttpClient

h2c = {
  "User-agent": 'python/' + str(sys.version.split()[0]),
  "Connection": "Upgrade, HTTP2-Settings",
  "Upgrade": "h2c",
  "HTTP2-Settings": "AAMAAABkAAQAAP__",
  "Accept": "*/*"
}

c = HttpClient.HTTPSConnection(ip, port) # IP and port given in arguments
c.request('HEAD', '/', None, h2c)
r = c.getresponse()
# Print result (see below)
</code></pre>

<p>I know it exists <a href="https://hyper.readthedocs.org/en/latest/index.html" rel="nofollow">hyper</a> but I don't always want SSL and currently certificate verification cannot be disabled with <em>hyper</em> </p>

<p>Here an example of my script running on localhost :</p>

<pre><code>➜  http2 git:(master) ✗ python3 main.py -i localhost -p 443

HEAD / HTTP/1.1
Host: localhost
Upgrade: h2c
User-agent: python/3.4.2
Accept: */*
Connection: Upgrade, HTTP2-Settings
HTTP2-Settings: AAMAAABkAAQAAP__

HTTP/1.1 200 OK
Server: nginx/1.9.12
Date: Tue, 22 Mar 2016 15:05:15 GMT
Content-Type: text/html
Content-Length: 867
Last-Modified: Mon, 21 Mar 2016 10:03:18 GMT
Connection: keep-alive
ETag: "56efc6e6-363"
Accept-Ranges: bytes
</code></pre>

<p>I checked and HTTP/2 is enable on my nginx server (with <code>curl --http2</code>)</p>

<p>If someone has an idea to force the server to reply HTTP 101 ...</p>