From ac96fd9c96b850c95f14a32bce1eb78b5e3f9c1b Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 24 Feb 2024 22:24:44 +0000 Subject: [PATCH] get rid of brotli due to poor support; closes #73 some reverse-proxies expect plaintext replies, and we don't have a brotli decompressor to satisfy this additionally, because brotli is https-gated (thx google), it was already an impractical mess anyways the sfx is now 7 KiB larger --- copyparty/httpcli.py | 20 +++++--------------- copyparty/httpsrv.py | 2 +- copyparty/web/md.js | 7 ------- docs/devnotes.md | 2 +- scripts/deps-docker/Dockerfile | 5 ++--- scripts/deps-docker/brotli.makefile | 4 ---- scripts/make-sfx.sh | 6 +++--- 7 files changed, 12 insertions(+), 34 deletions(-) delete mode 100644 scripts/deps-docker/brotli.makefile diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 12b0f68e..88b7c215 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -2827,11 +2827,11 @@ class HttpCli(object): logtail = "" # - # if request is for foo.js, check if we have foo.js.{gz,br} + # if request is for foo.js, check if we have foo.js.gz file_ts = 0.0 editions: dict[str, tuple[str, int]] = {} - for ext in ["", ".gz", ".br"]: + for ext in ("", ".gz"): try: fs_path = req_path + ext st = bos.stat(fs_path) @@ -2876,12 +2876,7 @@ class HttpCli(object): x.strip() for x in self.headers.get("accept-encoding", "").lower().split(",") ] - if ".br" in editions and "br" in supported_editions: - is_compressed = True - selected_edition = ".br" - fs_path, file_sz = editions[".br"] - self.out_headers["Content-Encoding"] = "br" - elif ".gz" in editions: + if ".gz" in editions: is_compressed = True selected_edition = ".gz" fs_path, file_sz = editions[".gz"] @@ -2897,13 +2892,8 @@ class HttpCli(object): is_compressed = False selected_edition = "plain" - try: - fs_path, file_sz = editions[selected_edition] - logmsg += "{} ".format(selected_edition.lstrip(".")) - except: - # client is old and we only have .br - # (could make brotli a dep to fix this but it's not worth) - raise Pebkac(404) + fs_path, file_sz = editions[selected_edition] + logmsg += "{} ".format(selected_edition.lstrip(".")) # # partial diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index 40bd108f..cade2df7 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -191,7 +191,7 @@ class HttpSrv(object): for fn in df: ap = absreal(os.path.join(dp, fn)) self.statics.add(ap) - if ap.endswith(".gz") or ap.endswith(".br"): + if ap.endswith(".gz"): self.statics.add(ap[:-3]) def set_netdevs(self, netdevs: dict[str, Netdev]) -> None: diff --git a/copyparty/web/md.js b/copyparty/web/md.js index 4dd29a37..d255b2c4 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -512,13 +512,6 @@ dom_navtgl.onclick = function () { redraw(); }; -if (!HTTPS && location.hostname != '127.0.0.1') try { - ebi('edit2').onclick = function (e) { - toast.err(0, "the fancy editor is only available over https"); - return ev(e); - } -} catch (ex) { } - if (sread('hidenav') == 1) dom_navtgl.onclick(); diff --git a/docs/devnotes.md b/docs/devnotes.md index 49023b81..72f331c0 100644 --- a/docs/devnotes.md +++ b/docs/devnotes.md @@ -218,7 +218,7 @@ if you don't need all the features, you can repack the sfx and save a bunch of s * `269k` after `./scripts/make-sfx.sh re no-cm no-hl` the features you can opt to drop are -* `cm`/easymde, the "fancy" markdown editor, saves ~82k +* `cm`/easymde, the "fancy" markdown editor, saves ~89k * `hl`, prism, the syntax hilighter, saves ~41k * `fnt`, source-code-pro, the monospace font, saves ~9k * `dd`, the custom mouse cursor for the media player tray tab, saves ~2k diff --git a/scripts/deps-docker/Dockerfile b/scripts/deps-docker/Dockerfile index 96c08e88..20e86a9e 100644 --- a/scripts/deps-docker/Dockerfile +++ b/scripts/deps-docker/Dockerfile @@ -24,7 +24,7 @@ ENV ver_asmcrypto=c72492f4a66e17a0e5dd8ad7874de354f3ccdaa5 \ # the scp url is regular latin from https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap RUN mkdir -p /z/dist/no-pk \ && wget https://fonts.gstatic.com/s/sourcecodepro/v11/HI_SiYsKILxRpg3hIP6sJ7fM7PqlPevW.woff2 -O scp.woff2 \ - && apk add cmake make g++ git bash npm patch wget tar pigz brotli gzip unzip python3 python3-dev brotli py3-brotli \ + && apk add cmake make g++ git bash npm patch wget tar pigz brotli gzip unzip python3 python3-dev py3-brotli \ && rm -f /usr/lib/python3*/EXTERNALLY-MANAGED \ && wget https://github.com/openpgpjs/asmcrypto.js/archive/$ver_asmcrypto.tar.gz -O asmcrypto.tgz \ && wget https://github.com/markedjs/marked/archive/v$ver_marked.tar.gz -O marked.tgz \ @@ -143,9 +143,8 @@ RUN ./genprism.sh $ver_prism # compress -COPY brotli.makefile zopfli.makefile /z/dist/ +COPY zopfli.makefile /z/dist/ RUN cd /z/dist \ - && make -j$(nproc) -f brotli.makefile \ && make -j$(nproc) -f zopfli.makefile \ && rm *.makefile \ && mv no-pk/* . \ diff --git a/scripts/deps-docker/brotli.makefile b/scripts/deps-docker/brotli.makefile deleted file mode 100644 index 3860224f..00000000 --- a/scripts/deps-docker/brotli.makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: $(addsuffix .br, $(wildcard easymde*)) - -%.br: % - brotli -jZ $< diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 0c77f5f2..53c6d2d0 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -37,7 +37,7 @@ help() { exec cat <<'EOF' # _____________________________________________________________________ # web features: # -# `no-cm` saves ~82k by removing easymde/codemirror +# `no-cm` saves ~89k by removing easymde/codemirror # (the fancy markdown editor) # # `no-hl` saves ~41k by removing syntax hilighting in the text viewer @@ -406,7 +406,7 @@ find -type f -name ._\* | while IFS= read -r f; do cmp <(printf '\x00\x05\x16') rm -f copyparty/web/deps/*.full.* copyparty/web/dbg-* copyparty/web/Makefile -find copyparty | LC_ALL=C sort | sed -r 's/\.(gz|br)$//;s/$/,/' > have +find copyparty | LC_ALL=C sort | sed -r 's/\.gz$//;s/$/,/' > have cat have | while IFS= read -r x; do grep -qF -- "$x" ../scripts/sfx.ls || { echo "unexpected file: $x" @@ -603,7 +603,7 @@ sed -r 's/(.*)\.(.*)/\2 \1/' | LC_ALL=C sort | sed -r 's/([^ ]*) (.*)/\2.\1/' | grep -vE '/list1?$' > list1 for n in {1..50}; do - (grep -vE '\.(gz|br)$' list1; grep -E '\.(gz|br)$' list1 | (shuf||gshuf) ) >list || true + (grep -vE '\.gz$' list1; grep -E '\.gz$' list1 | (shuf||gshuf) ) >list || true s=$( (sha1sum||shasum) < list | cut -c-16) grep -q $s "$zdir/h" 2>/dev/null && continue echo $s >> "$zdir/h"