mirror of
https://github.com/9001/copyparty.git
synced 2026-04-02 22:08:38 +10:00
optimize CL/TE check;
replace the heavyhanded connection:close added in b4fddbc3d
with a comparison of content-length to num bytes consumed
this approach also covers incorrectly configured servers
where the reverseproxy was not detected
also adds explicit TE/CL handling, even though most
(all?) reverseproxies already prevent such issues
also adds explicit sanchk of up2k chunk-receiver,
in case any bugs are ever added there
This commit is contained in:
@@ -222,6 +222,21 @@ class HttpConn(object):
|
||||
if not self.cli.run():
|
||||
return
|
||||
|
||||
if self.sr.te == 1:
|
||||
self.log("closing socket (leftover TE)", "90")
|
||||
return
|
||||
|
||||
if (
|
||||
"content-length" in self.cli.headers
|
||||
and int(self.cli.headers["content-length"]) != self.sr.nb
|
||||
):
|
||||
self.log("closing socket (CL mismatch)", "90")
|
||||
return
|
||||
|
||||
# note: proxies reject PUT sans Content-Length; illegal for HTTP/1.1
|
||||
|
||||
self.sr.nb = self.sr.te = 0
|
||||
|
||||
if self.u2idx:
|
||||
self.hsrv.put_u2idx(str(self.addr), self.u2idx)
|
||||
self.u2idx = None
|
||||
|
||||
Reference in New Issue
Block a user