mirror of
https://github.com/lgandx/Responder.git
synced 2025-07-06 04:51:23 -07:00
Fix socket timeout on HTTP POST requests
Remaining size should be checked at the end of the loop, the current implementation hang when POST request Content-Lenght is 0. We want to check for Content-Length header only if we received full header.
This commit is contained in:
parent
7339411766
commit
e7a787cbc4
1 changed files with 8 additions and 9 deletions
|
@ -278,21 +278,20 @@ class HTTP(BaseRequestHandler):
|
||||||
break
|
break
|
||||||
data += buff
|
data += buff
|
||||||
remaining -= len(buff)
|
remaining -= len(buff)
|
||||||
if remaining <= 0:
|
|
||||||
break
|
|
||||||
#check if we recieved the full header
|
#check if we recieved the full header
|
||||||
if data.find('\r\n\r\n') != -1:
|
if data.find('\r\n\r\n') != -1:
|
||||||
#we did, now to check if there was anything else in the request besides the header
|
#we did, now to check if there was anything else in the request besides the header
|
||||||
if data.find('Content-Length') == -1:
|
if data.find('Content-Length') == -1:
|
||||||
#request contains only header
|
#request contains only header
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
#searching for that content-length field in the header
|
#searching for that content-length field in the header
|
||||||
for line in data.split('\r\n'):
|
for line in data.split('\r\n'):
|
||||||
if line.find('Content-Length') != -1:
|
if line.find('Content-Length') != -1:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
remaining = int(line.split(':')[1].strip()) - len(data)
|
remaining = int(line.split(':')[1].strip()) - len(data)
|
||||||
|
if remaining <= 0:
|
||||||
|
break
|
||||||
if data == "":
|
if data == "":
|
||||||
break
|
break
|
||||||
#now the data variable has the full request
|
#now the data variable has the full request
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue