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:
Crypt0-M3lon 2019-02-08 09:08:24 +01:00 committed by GitHub
parent 7339411766
commit e7a787cbc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -278,8 +278,6 @@ class HTTP(BaseRequestHandler):
break
data += buff
remaining -= len(buff)
if remaining <= 0:
break
#check if we recieved the full header
if data.find('\r\n\r\n') != -1:
#we did, now to check if there was anything else in the request besides the header
@ -292,7 +290,8 @@ class HTTP(BaseRequestHandler):
if line.find('Content-Length') != -1:
line = line.strip()
remaining = int(line.split(':')[1].strip()) - len(data)
if remaining <= 0:
break
if data == "":
break
#now the data variable has the full request