Cédric Krier pushed to branch branch/default at Tryton / Website
Commits:
ccc7bf7c by Cédric Krier at 2023-01-10T14:23:55+01:00
Test URL with HEAD and fallback to GET
- - - - -
1 changed file:
- tests/test_app.py
Changes:
=====================================
tests/test_app.py
=====================================
@@ -63,12 +63,20 @@
if _skip(href) or href in _HREF_VISITED:
continue
with self.subTest(href=href):
- response = requests.get(
- href, verify=_verify(href),
- headers={
- # Some sites forbid python-requests
- 'User-Agent': 'Mozilla/5.0',
- })
+ verify = _verify(href)
+ headers = {
+ # Some sites forbid python-requests
+ 'User-Agent': 'Mozilla/5.0',
+ }
+ response = requests.head(
+ href, verify=verify, allow_redirects=True,
+ headers=headers)
+ if response.status_code in {
+ HTTPStatus.FORBIDDEN,
+ HTTPStatus.METHOD_NOT_ALLOWED,
+ }:
+ response = requests.get(
+ href, verify=verify, headers=headers)
response.raise_for_status()
_HREF_VISITED.add(href)
View it on Heptapod:
https://foss.heptapod.net/tryton/website/-/commit/ccc7bf7c6fc3b322c7a5c0150fb1f14f7bc4801e
--
View it on Heptapod:
https://foss.heptapod.net/tryton/website/-/commit/ccc7bf7c6fc3b322c7a5c0150fb1f14f7bc4801e
You're receiving this email because of your account on foss.heptapod.net.