Skip to content

Commit

Permalink
Add job option ignore_incomplete_reads.
Browse files Browse the repository at this point in the history
Sometimes web servers return incomplete responses, triggering an
`InvalidChunkLength` exception in urlwatch. Enable this job option to
ignore these errors.

#725
  • Loading branch information
wfrisch committed Feb 14, 2024
1 parent 0bc4abd commit 0ea72dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/urlwatch/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class UrlJob(Job):
__required__ = ('url',)
__optional__ = ('cookies', 'data', 'method', 'ssl_no_verify', 'ignore_cached', 'http_proxy', 'https_proxy',
'headers', 'ignore_connection_errors', 'ignore_http_error_codes', 'encoding', 'timeout',
'ignore_timeout_errors', 'ignore_too_many_redirects')
'ignore_timeout_errors', 'ignore_too_many_redirects', 'ignore_incomplete_reads')

CHARSET_RE = re.compile('text/(html|plain); charset=([^;]*)')

Expand Down Expand Up @@ -391,6 +391,8 @@ def ignore_error(self, exception):
return True
if isinstance(exception, requests.exceptions.TooManyRedirects) and self.ignore_too_many_redirects:
return True
if isinstance(exception, requests.exceptions.ChunkedEncodingError) and self.ignore_incomplete_reads:
return True
elif isinstance(exception, requests.exceptions.HTTPError):
status_code = exception.response.status_code
ignored_codes = []
Expand Down

0 comments on commit 0ea72dc

Please sign in to comment.