-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhttp_utils.py
34 lines (28 loc) · 912 Bytes
/
http_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class HttpParser:
__http_error_code = None
__http_response = None
def __init__(self):
"""
The constructor for HttpParser class
"""
self.__http_error_code = None
self.__http_response = None
def parse_http(self, http_res):
"""
This function is used to parse the HTTP response and return back the HTTP status code
Return:
HTTP status code.
"""
if http_res:
self.__http_error_code = http_res.status_code
if self.__http_error_code == 200:
self.__http_response = http_res.text
else:
self.__http_response = None
return self.__http_error_code
else:
return 0
def get_http_err_code(self):
return self.__http_error_code
def get_http_response(self):
return self.__http_response