Drop HSTS Preloading (#1110)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Drop HSTS Preloading * Update test_client.py
authored by Florimond Manca · committed by GitHub · parent d7aa6e0 · Browse files · 6 files·+6 added−33 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Tom Christie <tom@tomchristie.com>
Diff stats
6 files+6 added−33 removed
- tests:+4 added−19 removed
- other:+2 added−14 removed
Provenance
- Commit
78cf16a- Tree
70f6cdd- Author
Florimond Manca <florimond.manca@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
d7aa6e0
6 files changed+6 added−33 removed
modified:docs/index.md-1 removed
109 unmodified linesExpand all11011111211311411411511611717 unmodified lines109 unmodified linesExpand all * `h11` - HTTP/1.1 support. * `h2` - HTTP/2 support.* `certifi` - SSL certificates.* `chardet` - Fallback auto-detection for response encoding.* `hstspreload` - determines whether IDNA-encoded host should be only accessed via HTTPS.* `idna` - Internationalized domain name support.* `rfc3986` - URL parsing & normalization.* `sniffio` - Async library autodetection.* `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*17 unmodified linesmodified:httpx/_client.py+1 added-10 removed
1 import functools2 import typing3 from types import TracebackType4 5-import hstspreload5 import httpcore6 7 from ._auth import Auth, BasicAuth, FunctionAuth8 from ._config import (198 unmodified lines207 """208 Merge a URL argument together with any 'base_url' on the client,209 to create the URL used for the outgoing request.210 """212- url = self.base_url.join(relative_url=url)213- if (214- url.scheme == "http"215- and hstspreload.in_hsts_preload(url.host)216- and len(url.host.split(".")) > 1217- ):218- port = None if url.port == 80 else url.port219- url = url.copy_with(scheme="https", port=port)220- return url211+ return self.base_url.join(relative_url=url)212 213 def _merge_cookies(214 self, cookies: CookieTypes = None215 ) -> typing.Optional[CookieTypes]:1285 unmodified linesmodified:tests/client/test_client.py+4 added-19 removed
173 unmodified lines174 assert response.url == base_url175 176 177 def test_merge_url():178- client = httpx.Client(base_url="https://www.paypal.com/")179- request = client.build_request("GET", "http://www.paypal.com")180- assert request.url.scheme == "https"181- assert request.url.is_ssl178+ client = httpx.Client(base_url="https://www.example.com/")179+ request = client.build_request("GET", "http://www.example.com")180+ assert request.url.scheme == "http"181+ assert not request.url.is_ssl182 183 184-@pytest.mark.parametrize(185- "url,scheme,is_ssl",186- [187- ("http://www.paypal.com", "https", True),188- ("http://app", "http", False),189- ("http://192.168.1.42", "http", False),190- ],191-)192-def test_merge_url_hsts(url: str, scheme: str, is_ssl: bool):193- client = httpx.Client()194- request = client.build_request("GET", url)195- assert request.url.scheme == scheme196- assert request.url.is_ssl == is_ssl197-198-184 def test_pool_limits_deprecated():185 limits = httpx.Limits()186 187 with pytest.warns(DeprecationWarning):4 unmodified linesmodified:README.md-1 removed
111 unmodified lines112 * `h11` - HTTP/1.1 support.113 * `h2` - HTTP/2 support.114 * `certifi` - SSL certificates.115 * `chardet` - Fallback auto-detection for response encoding.116-* `hstspreload` - determines whether IDNA-encoded host should be only accessed via HTTPS.116 * `idna` - Internationalized domain name support.117 * `rfc3986` - URL parsing & normalization.118 * `sniffio` - Async library autodetection.119 * `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*8 unmodified linesmodified:setup.cfg+1 added-1 removed
12 unmodified lines13 [tool:isort]14 profile = black15 combine_as_imports = True16 known_first_party = httpx,tests17-known_third_party = brotli,certifi,chardet,cryptography,hstspreload,httpcore,pytest,rfc3986,setuptools,sniffio,trio,trustme,uvicorn17+known_third_party = brotli,certifi,chardet,cryptography,httpcore,pytest,rfc3986,setuptools,sniffio,trio,trustme,uvicorn18 19 [tool:pytest]20 addopts = --cov=httpx --cov=tests -rxXs21 markers =1 unmodified linemodified:setup.py-1 removed
54 unmodified lines55 include_package_data=True,56 zip_safe=False,57 install_requires=[58 "certifi",59- "hstspreload",59 "sniffio",60 "chardet==3.*",61 "idna==2.*",62 "rfc3986>=1.3,<2",18 unmodified lines