mirror of
https://github.com/9001/copyparty.git
synced 2026-10-05 22:04:38 +01:00
http206: fix footer (last-n-bytes) reqs
This commit is contained in:
@@ -4974,14 +4974,15 @@ class HttpCli(object):
|
|||||||
|
|
||||||
a, b = hrange.split("=", 1)[1].split("-")
|
a, b = hrange.split("=", 1)[1].split("-")
|
||||||
|
|
||||||
|
if b.strip():
|
||||||
|
upper = 1 + int(b.strip())
|
||||||
|
else:
|
||||||
|
upper = file_sz
|
||||||
|
|
||||||
if a.strip():
|
if a.strip():
|
||||||
lower = int(a.strip())
|
lower = int(a.strip())
|
||||||
else:
|
else:
|
||||||
lower = 0
|
lower = 1 + file_sz - upper
|
||||||
|
|
||||||
if b.strip():
|
|
||||||
upper = int(b.strip()) + 1
|
|
||||||
else:
|
|
||||||
upper = file_sz
|
upper = file_sz
|
||||||
|
|
||||||
if upper > file_sz:
|
if upper > file_sz:
|
||||||
|
|||||||
@@ -104,6 +104,22 @@ class TestHttpCli(unittest.TestCase):
|
|||||||
eprint("\033[33m{}\n# {}\033[0m".format(ret, furl))
|
eprint("\033[33m{}\n# {}\033[0m".format(ret, furl))
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
|
if tctr == 1:
|
||||||
|
# http206
|
||||||
|
full = ret
|
||||||
|
self.hcurl(furl, "Range: bytes=0-0", full[:1])
|
||||||
|
self.hcurl(furl, "Range: bytes=0-4", full[0:5])
|
||||||
|
self.hcurl(furl, "Range: bytes=1-4", full[1:5])
|
||||||
|
self.hcurl(furl, "Range: bytes=-1", full[-1:])
|
||||||
|
self.hcurl(furl, "Range: bytes=-7", full[-7:])
|
||||||
|
self.hcurl(furl, "Range: bytes=0-", full)
|
||||||
|
self.hcurl(furl, "Range: bytes=1-", full[1:])
|
||||||
|
self.hcurl(furl, "Range: bytes=2-", full[2:])
|
||||||
|
for zs in ("0--1", "--1", "-0", ""):
|
||||||
|
h, _ = self.hcurl(furl, "Range: bytes=" + zs, None)
|
||||||
|
self.assertEqual(h.split(" ")[1], "416")
|
||||||
|
return
|
||||||
|
|
||||||
# file browser: html
|
# file browser: html
|
||||||
h, ret = self.curl(durl)
|
h, ret = self.curl(durl)
|
||||||
res = "'{}'".format(self.fn) in ret
|
res = "'{}'".format(self.fn) in ret
|
||||||
@@ -243,6 +259,15 @@ class TestHttpCli(unittest.TestCase):
|
|||||||
|
|
||||||
return conn.s._reply.decode("utf-8").split("\r\n\r\n", 1)
|
return conn.s._reply.decode("utf-8").split("\r\n\r\n", 1)
|
||||||
|
|
||||||
|
def hcurl(self, url, hdr, expected):
|
||||||
|
zs = "GET /%s HTTP/1.1\r\n%s\r\nCookie: cppwd=o\r\nConnection: close\r\n\r\n"
|
||||||
|
conn = self.conn.setbuf((zs % (url, hdr)).encode("utf-8"))
|
||||||
|
HttpCli(conn).run()
|
||||||
|
h, rsp = conn.s._reply.decode("utf-8").split("\r\n\r\n", 1)
|
||||||
|
if expected is not None:
|
||||||
|
self.assertEqual(rsp, expected)
|
||||||
|
return h, rsp
|
||||||
|
|
||||||
def propfind(self, url, depth=1):
|
def propfind(self, url, depth=1):
|
||||||
zs = "PROPFIND /%s HTTP/1.1\r\nDepth: %d\r\nPW: o\r\nConnection: close\r\n\r\n"
|
zs = "PROPFIND /%s HTTP/1.1\r\nDepth: %d\r\nPW: o\r\nConnection: close\r\n\r\n"
|
||||||
buf = zs % (url, depth)
|
buf = zs % (url, depth)
|
||||||
|
|||||||
Reference in New Issue
Block a user