Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Bugfix: Extracting data from byte response instead of string
  • Loading branch information
mertaksoy committed Nov 16, 2021
commit b6500493294fc37719f6c5494b2ddd0882ac260c
27 changes: 12 additions & 15 deletions httpParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,20 @@ def parseHTTP(self, httpRes):
Return:
HTTP status code.
"""
#print(">>>>",httpRes)
if(httpRes != None):
retParseResponse=str(httpRes).partition("+IPD,")[2]
#print(">>>>>>>>>>>>>>>>>",retParseResponse)
retParseResponse=retParseResponse.split(r"\r\n\r\n");
#print(">>>>>>>>>>>>>>>>>",retParseResponse[0])
self.__httpResponse = retParseResponse[1]
#print(">>>>>>>>>>>>>>>>>???",retParseResponse[1])
self.__httpHeader=str(retParseResponse[0]).partition(":")[2]
#print("--",self.__httpHeader)
if httpRes is not None:
self.__httpResponse = httpRes.split(b'\r\n\r\n')[3]

header = str(httpRes.split(b'\r\n\r\n')[2], 'utf-8')
self.__httpHeader = header[header.index('HTTP'):]

for code in str(self.__httpHeader.partition(r"\r\n")[0]).split():
if code.isdigit():
self.__httpErrCode=int(code)

if(self.__httpErrCode != 200):
self.__httpResponse=None

self.__httpErrCode = int(code)
break

if self.__httpErrCode != 200:
self.__httpResponse = None

return self.__httpErrCode
else:
return 0
Expand Down