revise_parse_request
This commit is contained in:
parent
c95ea86a3b
commit
92af6e21bf
@ -420,25 +420,30 @@ class Requests(object):
|
|||||||
while leng >0:
|
while leng >0:
|
||||||
body += input.read(leng+2)
|
body += input.read(leng+2)
|
||||||
leng = int(input.readline(),16)
|
leng = int(input.readline(),16)
|
||||||
|
print(body)
|
||||||
boundary=body.splitlines()[0]
|
boundary=body.splitlines()[0]
|
||||||
items=body.split(boundary)
|
items=body.split(boundary)
|
||||||
items.pop()
|
items.pop()
|
||||||
items.pop(0)
|
items.pop(0)
|
||||||
# parse data
|
# parse data
|
||||||
data_raw=items[0].strip()
|
data_raw=items[0].strip()
|
||||||
data_raw_li=data_raw.splitlines()
|
cd=data_raw.splitlines()[0]
|
||||||
data1=data_raw_li[3]
|
data_without_cd=data_raw[len(cd):].strip()
|
||||||
cd=data_raw_li[0]
|
if b'\r\n' in data_without_cd:
|
||||||
start_len=4*len(b'\r\n')+len(cd)+len(data1)
|
# case 2.1.44
|
||||||
data2=data_raw[start_len:]
|
data_raw_li=data_without_cd.splitlines()
|
||||||
data=data1+data2
|
data1=data_raw_li[0]
|
||||||
|
data2=data_without_cd[len(data1)+len(b'\r\n'):]
|
||||||
|
data=data1+data2
|
||||||
|
else:
|
||||||
|
# case 2.1.46
|
||||||
|
data=data_without_cd
|
||||||
|
print(data)
|
||||||
d['data']=data
|
d['data']=data
|
||||||
#
|
#
|
||||||
others=items[1:]
|
others=items[1:]
|
||||||
for i in others:
|
for i in others:
|
||||||
i=i.splitlines()
|
i=i.splitlines()
|
||||||
print(i)
|
|
||||||
key=re.findall(b'name="(.*?)"',i[2])[0].decode('utf-8')
|
key=re.findall(b'name="(.*?)"',i[2])[0].decode('utf-8')
|
||||||
v=i[-3].decode('utf-8')
|
v=i[-3].decode('utf-8')
|
||||||
d[key]=v
|
d[key]=v
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user