Ignore decoding error when charset is erroneous
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
45a27b477d
commit
84fef789b5
1 changed files with 2 additions and 2 deletions
|
@ -191,9 +191,9 @@ def getURLContent(url, body=None, timeout=7, header=None, decode_error=False,
|
|||
import http.client
|
||||
|
||||
if res.status == http.client.OK or res.status == http.client.SEE_OTHER:
|
||||
return data.decode(charset).strip()
|
||||
return data.decode(charset, errors='ignore').strip()
|
||||
elif decode_error:
|
||||
return data.decode(charset).strip()
|
||||
return data.decode(charset, errors='ignore').strip()
|
||||
else:
|
||||
raise IMException("A HTTP error occurs: %d - %s" %
|
||||
(res.status, http.client.responses[res.status]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue