Skip to content
Myr

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

6 files+6 added−33 removed

modified:docs/index.md-1 removed
modified:httpx/_client.py+1 added-10 removed
1import functools2import typing3from types import TracebackType45import hstspreload5import httpcore67from ._auth import Auth, BasicAuth, FunctionAuth8from ._config import (
198 unmodified lines
207 """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)212213 def _merge_cookies(214 self, cookies: CookieTypes = None215 ) -> typing.Optional[CookieTypes]:
1285 unmodified lines
modified:tests/client/test_client.py+4 added-19 removed
173 unmodified lines
174 assert response.url == base_url175176177def 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_ssl182183184@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)192def 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_ssl197198184def test_pool_limits_deprecated():185 limits = httpx.Limits()186187 with pytest.warns(DeprecationWarning):
4 unmodified lines
modified:README.md-1 removed
111 unmodified lines
112 * `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 lines
modified:setup.cfg+1 added-1 removed
12 unmodified lines
13[tool:isort]14profile = black15combine_as_imports = True16known_first_party = httpx,tests17known_third_party = brotli,certifi,chardet,cryptography,hstspreload,httpcore,pytest,rfc3986,setuptools,sniffio,trio,trustme,uvicorn17known_third_party = brotli,certifi,chardet,cryptography,httpcore,pytest,rfc3986,setuptools,sniffio,trio,trustme,uvicorn1819[tool:pytest]20addopts = --cov=httpx --cov=tests -rxXs21markers =
1 unmodified line
modified:setup.py-1 removed
54 unmodified lines
55 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