|
14 | 14 | from pprint import pformat
|
15 | 15 | from textwrap import dedent
|
16 | 16 |
|
17 |
| -from hyper import HTTPConnection |
| 17 | +from hyper import HTTPConnection, HTTP20Connection |
18 | 18 | from hyper import __version__
|
19 | 19 | from hyper.compat import is_py2, urlencode, urlsplit, write_to_stdout
|
20 | 20 |
|
@@ -105,6 +105,9 @@ def make_troubleshooting_argument(parser):
|
105 | 105 | parser.add_argument(
|
106 | 106 | '--debug', action='store_true', default=False,
|
107 | 107 | 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") |
108 | 111 |
|
109 | 112 |
|
110 | 113 | def set_url_info(args):
|
@@ -218,7 +221,15 @@ def get_content_type_and_charset(response):
|
218 | 221 |
|
219 | 222 |
|
220 | 223 | 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 | + |
222 | 233 | conn.request(args.method, args.url.path, args.body, args.headers)
|
223 | 234 | response = conn.get_response()
|
224 | 235 | log.debug('Response Headers:\n%s', pformat(response.headers))
|
|
0 commit comments