improve http206 and fuse-client

This commit is contained in:
ed
2020-05-15 00:00:49 +02:00
parent db5f07f164
commit 2e33c8d222
3 changed files with 37 additions and 39 deletions

View File

@@ -80,8 +80,9 @@ class HttpSrv(object):
"%s %s" % addr,
"shut_rdwr err:\n {}\n {}".format(repr(sck), ex),
)
if ex.errno not in [10038, 107, 57, 9]:
if ex.errno not in [10038, 10054, 107, 57, 9]:
# 10038 No longer considered a socket
# 10054 Foribly closed by remote
# 107 Transport endpoint not connected
# 57 Socket is not connected
# 9 Bad file descriptor

View File

@@ -309,18 +309,7 @@ def get_boundary(headers):
def read_header(sr):
ret = b""
while True:
if ret.endswith(b"\r\n\r\n"):
break
elif ret.endswith(b"\r\n\r"):
n = 1
elif ret.endswith(b"\r\n"):
n = 2
elif ret.endswith(b"\r"):
n = 3
else:
n = 4
buf = sr.recv(n)
buf = sr.recv(1024)
if not buf:
if not ret:
return None
@@ -332,11 +321,15 @@ def read_header(sr):
)
ret += buf
ofs = ret.find(b"\r\n\r\n")
if ofs < 0:
if len(ret) > 1024 * 64:
raise Pebkac(400, "header 2big")
else:
continue
if len(ret) > 1024 * 64:
raise Pebkac(400, "header 2big")
return ret[:-4].decode("utf-8", "surrogateescape").split("\r\n")
sr.unrecv(ret[ofs + 4 :])
return ret[:ofs].decode("utf-8", "surrogateescape").split("\r\n")
def undot(path):