Skip to content

Commit 9525f59

Browse files
committed
add 404 support for http_request
1 parent 763fae3 commit 9525f59

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

kubesys/http_request.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ def createRequest(url, token, method="GET", body=None, verify=False,
1717
keep_json=False, config=None, **kwargs) -> Union[object, bool, str]:
1818
response, OK, status_code = doCreateRequest(
1919
formatURL(url, getParams(kwargs)), token, method, body, config)
20-
21-
result = response.json()
22-
if keep_json:
23-
result = json.dumps(result, indent=4, separators=(',', ': '))
24-
25-
return result, OK, status_code
20+
try:
21+
result = response.json()
22+
if keep_json:
23+
result = json.dumps(result, indent=4, separators=(',', ': '))
24+
25+
return result, OK, status_code
26+
except:
27+
return response, OK, status_code
2628

2729

2830
def doCreateRequest(url, token, method="GET", body=None, config=None,stream=False) \

0 commit comments

Comments
 (0)