cleanup + optimizations

This commit is contained in:
ed 2022-12-11 14:16:51 +00:00
parent db194ab519
commit 19cd96e392
4 changed files with 14 additions and 13 deletions

View file

@ -10,6 +10,8 @@
# #
# you may also consider adding -j0 for CPU-intensive configurations # you may also consider adding -j0 for CPU-intensive configurations
# (not that i can really think of any good examples) # (not that i can really think of any good examples)
#
# on fedora/rhel, remember to setsebool -P httpd_can_network_connect 1
upstream cpp { upstream cpp {
server 127.0.0.1:3923; server 127.0.0.1:3923;

View file

@ -370,7 +370,6 @@ class VFS(object):
def _find(self, vpath: str) -> tuple["VFS", str]: def _find(self, vpath: str) -> tuple["VFS", str]:
"""return [vfs,remainder]""" """return [vfs,remainder]"""
vpath = undot(vpath)
if vpath == "": if vpath == "":
return self, "" return self, ""
@ -381,7 +380,7 @@ class VFS(object):
rem = "" rem = ""
if name in self.nodes: if name in self.nodes:
return self.nodes[name]._find(rem) return self.nodes[name]._find(undot(rem))
return self, vpath return self, vpath
@ -389,7 +388,7 @@ class VFS(object):
self, vpath: str, uname: str self, vpath: str, uname: str
) -> tuple[bool, bool, bool, bool, bool, bool]: ) -> tuple[bool, bool, bool, bool, bool, bool]:
"""can Read,Write,Move,Delete,Get,Upget""" """can Read,Write,Move,Delete,Get,Upget"""
vn, _ = self._find(vpath) vn, _ = self._find(undot(vpath))
c = vn.axs c = vn.axs
return ( return (
uname in c.uread or "*" in c.uread, uname in c.uread or "*" in c.uread,
@ -419,7 +418,7 @@ class VFS(object):
self.log("vfs", "invalid relpath [{}]".format(vpath)) self.log("vfs", "invalid relpath [{}]".format(vpath))
raise Pebkac(404) raise Pebkac(404)
vn, rem = self._find(vpath) vn, rem = self._find(undot(vpath))
c: AXS = vn.axs c: AXS = vn.axs
for req, d, msg in [ for req, d, msg in [

View file

@ -119,7 +119,6 @@ class HttpCli(object):
# placeholders; assigned by run() # placeholders; assigned by run()
self.keepalive = False self.keepalive = False
self.is_https = False self.is_https = False
self.is_proxied = False
self.is_vproxied = False self.is_vproxied = False
self.in_hdr_recv = True self.in_hdr_recv = True
self.headers: dict[str, str] = {} self.headers: dict[str, str] = {}
@ -256,7 +255,7 @@ class HttpCli(object):
self.is_ancient = self.ua.startswith("Mozilla/4.") self.is_ancient = self.ua.startswith("Mozilla/4.")
zs = self.headers.get("connection", "").lower() zs = self.headers.get("connection", "").lower()
self.keepalive = not zs.startswith("close") and ( self.keepalive = "close" not in zs and (
self.http_ver != "HTTP/1.0" or zs == "keep-alive" self.http_ver != "HTTP/1.0" or zs == "keep-alive"
) )
self.is_https = ( self.is_https = (
@ -280,7 +279,6 @@ class HttpCli(object):
self.log_src = self.conn.set_rproxy(self.ip) self.log_src = self.conn.set_rproxy(self.ip)
self.is_vproxied = bool(self.args.R) self.is_vproxied = bool(self.args.R)
self.is_proxied = True
if self.is_banned(): if self.is_banned():
return False return False
@ -1149,7 +1147,11 @@ class HttpCli(object):
if "multipart/form-data" in ctype: if "multipart/form-data" in ctype:
return self.handle_post_multipart() return self.handle_post_multipart()
if "text/plain" in ctype or "application/xml" in ctype: if (
"application/json" in ctype
or "text/plain" in ctype
or "application/xml" in ctype
):
return self.handle_post_json() return self.handle_post_json()
if "application/octet-stream" in ctype: if "application/octet-stream" in ctype:

View file

@ -306,11 +306,9 @@ class SvcHub(object):
t = "found URL in --webroot; it should be just the location, for example /foo/bar" t = "found URL in --webroot; it should be just the location, for example /foo/bar"
raise Exception(t) raise Exception(t)
R = R.strip("/") al.R = R = R.strip("/")
if R: al.SR = "/" + R if R else ""
al.R = R al.RS = R + "/" if R else ""
al.SR = "/" + R
al.RS = R + "/"
return True return True