Improve html error detection

In case the header is not correctly set, try to detect html error messages
from the content itself
This commit is contained in:
Roland Geider
2026-01-14 14:59:07 +01:00
parent 57f3df846b
commit 6620a83baa
4 changed files with 39 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2020 - 2025 wger Team
* Copyright (c) 2020 - 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -43,7 +43,8 @@ class WgerHttpException implements Exception {
final dynamic responseBody = response.body;
final contentType = response.headers[HttpHeaders.contentTypeHeader];
if (contentType != null && contentType.contains('text/html')) {
if ((contentType != null && contentType.contains('text/html')) ||
responseBody.toString().contains('<html')) {
type = ErrorType.html;
}