[FIX] link_tracker: get redirected page title instead of URL
In 2e3075693b06d71222b446bd8a805dacb639d0e4 we used a head request to determine type of page before trying to get a title out of it. But requests.head does not allow redirect by default: https://docs.python-requests.org/en/v2.9.1/user/quickstart/#redirection-and-history so if an URL was a redirect, we would not longer get the page title. opw-2457640 closes odoo/odoo#84832 X-original-commit: 63346cf4b77f760121f88762ab2911c37603b548 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -116,7 +116,7 @@ class LinkTracker(models.Model):
|
||||
@api.depends('url')
|
||||
def _get_title_from_url(self, url):
|
||||
try:
|
||||
head = requests.head(url, timeout=5)
|
||||
head = requests.head(url, allow_redirects=True, timeout=5)
|
||||
if (
|
||||
int(head.headers.get('Content-Length', 0)) > URL_MAX_SIZE
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user