From caa0aa3fb4463322691664130332d570529c46b6 Mon Sep 17 00:00:00 2001 From: Piotr Wiercinski Date: Mon, 24 Mar 2025 12:59:29 +0100 Subject: [PATCH] wasm: Fix Brotli compression in qtwasmserver.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is not compress() function in brotli.Compressor API. Use process(). Use requirements.txt instead of Pipfile. Change-Id: I55a0263f16f36bcb4b96e443f85925b7d5dd15af Reviewed-by: Morten Johan Sørvig --- util/wasm/qtwasmserver/Pipfile | 12 ------------ util/wasm/qtwasmserver/qtwasmserver.py | 6 +----- util/wasm/qtwasmserver/requirements.txt | 3 +++ 3 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 util/wasm/qtwasmserver/Pipfile create mode 100644 util/wasm/qtwasmserver/requirements.txt diff --git a/util/wasm/qtwasmserver/Pipfile b/util/wasm/qtwasmserver/Pipfile deleted file mode 100644 index ef542c10487..00000000000 --- a/util/wasm/qtwasmserver/Pipfile +++ /dev/null @@ -1,12 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -netifaces = "*" - -[dev-packages] - -[requires] -python_version = "3.9" diff --git a/util/wasm/qtwasmserver/qtwasmserver.py b/util/wasm/qtwasmserver/qtwasmserver.py index 208717a0bad..07ea1c6a249 100755 --- a/util/wasm/qtwasmserver/qtwasmserver.py +++ b/util/wasm/qtwasmserver/qtwasmserver.py @@ -4,15 +4,11 @@ import argparse import os -import pathlib -import socket import ssl import subprocess -import sys import tempfile import threading from enum import Enum -from http import HTTPStatus from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer from subprocess import run from functools import partial @@ -110,7 +106,7 @@ class CompressionHttpRequesthandler(HTTPCompressionRequestHandler): if not buf: yield compressor.finish() return - yield compressor.compress(buf) + yield compressor.process(buf) # must flush compressor state to work around crash/assert in brotlicffi, # see https://github.com/python-hyper/brotlicffi/issues/167 diff --git a/util/wasm/qtwasmserver/requirements.txt b/util/wasm/qtwasmserver/requirements.txt new file mode 100644 index 00000000000..3a30de1264d --- /dev/null +++ b/util/wasm/qtwasmserver/requirements.txt @@ -0,0 +1,3 @@ +Brotli==1.1.0 +httpcompressionserver==0.5 +netifaces==0.11.0