Skip to content
Myr

HTTP/2 becomes fully optional (#1140)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* HTTP/2 becomes fully optional * Fix linting, coverage

authored by Tom Christie · committed by GitHub · parent 360b63d · Browse files · 8 files+47 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+47 added−8 removed

  • tests:+2 added−2 removed
  • other:+45 added−6 removed

8 files+47 added−8 removed

modified:docs/http2.md+9 added-3 removed
modified:docs/index.md+6 added
127 unmodified lines
128```shell129$ pip install httpx130```131132Or, to include the optional HTTP/2 support, use:133134```shell135$ pip install httpx[http2]136```137138HTTPX requires Python 3.6+139140[sync-support]: https://github.com/encode/httpx/issues/572
modified:httpx/_client.py+18 added
475 unmodified lines
476 base_url=base_url,477 trust_env=trust_env,478 )479480 if http2:481 try:482 import h2 # noqa483 except ImportError: # pragma: nocover484 raise ImportError(485 "Using http2=True, but the 'h2' package is not installed. "486 "Make sure to install httpx using `pip install httpx[http2]`."487 ) from None488489 if pool_limits is not None:490 warn_deprecated(491 "Client(..., pool_limits=...) is deprecated and will raise "492 "errors in the future. Use Client(..., limits=...) instead."
516 unmodified lines
1009 base_url=base_url,1010 trust_env=trust_env,1011 )10121013 if http2:1014 try:1015 import h2 # noqa1016 except ImportError: # pragma: nocover1017 raise ImportError(1018 "Using http2=True, but the 'h2' package is not installed. "1019 "Make sure to install httpx using `pip install httpx[http2]`."1020 ) from None10211022 if pool_limits is not None:1023 warn_deprecated(1024 "AsyncClient(..., pool_limits=...) is deprecated and will raise "1025 "errors in the future. Use AsyncClient(..., limits=...) instead."
504 unmodified lines
modified:tests/client/test_async_client.py+1 added-1 removed
6 unmodified lines
78@pytest.mark.usefixtures("async_environment")9async def test_get(server):10 url = server.url11 async with httpx.AsyncClient() as client:11 async with httpx.AsyncClient(http2=True) as client:12 response = await client.get(url)13 assert response.status_code == 20014 assert response.text == "Hello, world!"15 assert response.http_version == "HTTP/1.1"
153 unmodified lines
modified:tests/client/test_client.py+1 added-1 removed
5 unmodified lines
678def test_get(server):9 url = server.url10 with httpx.Client() as http:10 with httpx.Client(http2=True) as http:11 response = http.get(url)12 assert response.status_code == 20013 assert response.url == url14 assert response.content == b"Hello, world!"
196 unmodified lines
modified:README.md+7 added-1 removed
modified:requirements.txt+1 added-1 removed
1-e .1-e .[http2]23# Optional4brotlipy==0.7.*5
29 unmodified lines
modified:setup.py+4 added-1 removed
58 unmodified lines
59 "sniffio",60 "chardet==3.*",61 "idna==2.*",62 "rfc3986>=1.3,<2",63 "httpcore[http2]==0.10.*",63 "httpcore==0.10.*",64 ],65 extras_require={66 "http2": "h2==3.*",67 },68 classifiers=[69 "Development Status :: 4 - Beta",70 "Environment :: Web Environment",71 "Intended Audience :: Developers",
12 unmodified lines