reduce timeout of unbounded socket reads;

if a request body is expected, but request has no content-length,
set the timeout to 1/20 of `--s-tbody`, so 9 seconds by default,
or 3 seconds if it's 60 as recommended in helptext

this gives less confusing behavior if a client accidentally does
something invalid, replying with an error response before the
previous timeout of 186 seconds

also raise the slowloris flag, in case a client bugs out and
keeps making such requests
This commit is contained in:
ed 2024-07-10 11:14:42 +02:00
parent 927c3bce96
commit c549f367c1

View file

@ -1678,6 +1678,8 @@ class HttpCli(object):
remains = int(self.headers.get("content-length", -1))
if remains == -1:
self.keepalive = False
self.in_hdr_recv = True
self.s.settimeout(max(self.args.s_tbody // 20, 1))
return read_socket_unbounded(self.sr, bufsz), remains
else:
return read_socket(self.sr, bufsz, remains), remains