mirror of
https://github.com/yawaflua/Py-SPW.git
synced 2026-02-04 18:34:16 +02:00
fix unreasonable spworlds api DDOS error
v1.5.2
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import platform
|
import platform
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
@@ -57,7 +58,10 @@ class SpApi:
|
|||||||
except rq.exceptions.ConnectionError as error:
|
except rq.exceptions.ConnectionError as error:
|
||||||
raise err.SpwApiError(error)
|
raise err.SpwApiError(error)
|
||||||
|
|
||||||
if response.headers.get('Content-Type') != 'application/json':
|
try:
|
||||||
|
response.json()
|
||||||
|
|
||||||
|
except json.JSONDecodeError:
|
||||||
raise err.SpwApiDDOS()
|
raise err.SpwApiDDOS()
|
||||||
|
|
||||||
if response.ok or response.status_code in ignore_codes:
|
if response.ok or response.status_code in ignore_codes:
|
||||||
|
|||||||
Reference in New Issue
Block a user