mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Ignore it when flaky instances provide a HTML instead of JSON response
This commit is contained in:
parent
123536b006
commit
12f488bfc1
1 changed files with 4 additions and 1 deletions
|
@ -103,9 +103,12 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con
|
|||
result = HttpSignature.signed_request(uri, body, private_key, key_id, content_type, method, timeout)
|
||||
if result.status_code != 200 and result.status_code != 202 and result.status_code != 204:
|
||||
log.result = 'failure'
|
||||
log.exception_message += f' Response status code was {result.status_code}'
|
||||
log.exception_message = f'{result.status_code}: {result.text:.100}' + ' - '
|
||||
current_app.logger.error(f'Response code for post attempt to {uri} was ' +
|
||||
str(result.status_code) + ' ' + result.text)
|
||||
if 'DOCTYPE html' in result.text:
|
||||
log.result = 'ignored'
|
||||
log.exception_message = f'{result.status_code}: HTML instead of JSON response - '
|
||||
log.exception_message += uri
|
||||
if result.status_code == 202:
|
||||
log.exception_message += ' 202'
|
||||
|
|
Loading…
Add table
Reference in a new issue