Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 8f53a84

Browse files
committed
Allow fallback to HTTP/2-only in plaintext in cli.
1 parent 75ac14f commit 8f53a84

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

hyper/cli.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pprint import pformat
1515
from textwrap import dedent
1616

17-
from hyper import HTTPConnection
17+
from hyper import HTTPConnection, HTTP20Connection
1818
from hyper import __version__
1919
from hyper.compat import is_py2, urlencode, urlsplit, write_to_stdout
2020

@@ -105,6 +105,9 @@ def make_troubleshooting_argument(parser):
105105
parser.add_argument(
106106
'--debug', action='store_true', default=False,
107107
help='Show debugging information (loglevel=DEBUG)')
108+
parser.add_argument(
109+
'--h2', action='store_true', default=False,
110+
help="Do HTTP/2 directly in plaintext: skip plaintext upgrade")
108111

109112

110113
def set_url_info(args):
@@ -218,7 +221,15 @@ def get_content_type_and_charset(response):
218221

219222

220223
def request(args):
221-
conn = HTTPConnection(args.url.host, args.url.port, secure=args.url.secure)
224+
if not args.h2:
225+
conn = HTTPConnection(
226+
args.url.host, args.url.port, secure=args.url.secure
227+
)
228+
else: # pragma: no cover
229+
conn = HTTP20Connection(
230+
args.url.host, args.url.port, secure=args.url.secure
231+
)
232+
222233
conn.request(args.method, args.url.path, args.body, args.headers)
223234
response = conn.get_response()
224235
log.debug('Response Headers:\n%s', pformat(response.headers))

0 commit comments

Comments
 (0)