revise_parse_req_to_correctly_parse_chunked_data
This commit is contained in:
parent
cdfa5c4191
commit
0eaf60feca
@ -430,14 +430,14 @@ class Requests(object):
|
|||||||
elif c>=3:
|
elif c>=3:
|
||||||
# data
|
# data
|
||||||
data_other.append(dt)
|
data_other.append(dt)
|
||||||
line=input.readline()
|
leng = int(input.readline(),16)
|
||||||
leng = int(line,16)
|
|
||||||
print(line)
|
|
||||||
data_other=[item for item in data_other if item!=b'\r\n\r\n']
|
data_other=[item for item in data_other if item!=b'\r\n\r\n']
|
||||||
for item in data_other:
|
for item in data_other:
|
||||||
if bdry in item:
|
if bdry in item:
|
||||||
break
|
break
|
||||||
data.append(item.strip())
|
# only strip \r\n if there are extra \n
|
||||||
|
# eg b'?V\xc1\x8f>\xf9\xb1\n\r\n'
|
||||||
|
data.append(item[:-2])
|
||||||
d['data']=b''.join(data)
|
d['data']=b''.join(data)
|
||||||
others=data_other[len(data):]
|
others=data_other[len(data):]
|
||||||
boundary=others[0]
|
boundary=others[0]
|
||||||
@ -448,30 +448,7 @@ class Requests(object):
|
|||||||
i=i.splitlines()
|
i=i.splitlines()
|
||||||
key=re.findall(b'name="(.*?)"',i[2],flags=re.M)[0].decode('utf-8')
|
key=re.findall(b'name="(.*?)"',i[2],flags=re.M)[0].decode('utf-8')
|
||||||
v=i[-1].decode('utf-8')
|
v=i[-1].decode('utf-8')
|
||||||
d[key]=v
|
d[key]=v
|
||||||
# boundary=body.splitlines()[0]
|
|
||||||
# items=body.split(boundary)
|
|
||||||
# items.pop()
|
|
||||||
# items.pop(0)
|
|
||||||
# # parse data
|
|
||||||
# data_raw=items[0].strip()
|
|
||||||
# cd=data_raw.splitlines()[0]
|
|
||||||
# data_without_cd=data_raw[len(cd):].strip()
|
|
||||||
# data=b''
|
|
||||||
# if b'\r\n' in data_without_cd:
|
|
||||||
# # seems b'\r\n' should not exist in data
|
|
||||||
# data=re.sub(b'\r\n',b'',data_without_cd,flags=re.M)
|
|
||||||
# else:
|
|
||||||
# data=data_without_cd
|
|
||||||
# d['data']=data
|
|
||||||
# #
|
|
||||||
# others=items[1:]
|
|
||||||
# for i in others:
|
|
||||||
# i=i.splitlines()
|
|
||||||
# key=re.findall(b'name="(.*?)"',i[2])[0].decode('utf-8')
|
|
||||||
# v=i[-3].decode('utf-8')
|
|
||||||
# d[key]=v
|
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
if self.query_string !='':
|
if self.query_string !='':
|
||||||
@ -645,7 +622,6 @@ class SyncApp:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = p['data']
|
data = p['data']
|
||||||
print(compression)
|
|
||||||
data = self._decode_data(data, compression)
|
data = self._decode_data(data, compression)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data = {}
|
data = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user