Skip to content

Commit 6127862

Browse files
fix(upload): re-implement LimitedStream for Werkzeug 3.x compatibility
- Removes the broken import of LimitedStream from werkzeug.wsgi - Adds a local, minimal implementation of LimitedStream - Ensures file upload functionality works on modern versions of Werkzeug
1 parent ef98904 commit 6127862

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

qrtunnel.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,34 @@
3535

3636
from streaming_form_data import StreamingFormDataParser
3737
from streaming_form_data.targets import FileTarget
38-
from werkzeug.wsgi import LimitedStream
38+
39+
40+
# ── LimitedStream (Manual Implementation) ────────────────
41+
# Werkzeug 3.0.0 removed LimitedStream. Re-implementing a
42+
# minimal version to ensure upload stability.
43+
class LimitedStream:
44+
def __init__(self, stream, limit):
45+
self._stream = stream
46+
self._limit = limit
47+
self._pos = 0
48+
49+
def read(self, size=-1):
50+
if self._pos >= self._limit:
51+
return b""
52+
if size < 0 or size > self._limit - self._pos:
53+
size = self._limit - self._pos
54+
data = self._stream.read(size)
55+
self._pos += len(data)
56+
return data
57+
58+
def readline(self, size=-1):
59+
if self._pos >= self._limit:
60+
return b""
61+
if size < 0 or size > self._limit - self._pos:
62+
size = self._limit - self._pos
63+
data = self._stream.readline(size)
64+
self._pos += len(data)
65+
return data
3966

4067
# ─────────────────────────────────────────────────────────
4168
# TERMINAL COLOURS & ICONS (Neat Palette)

0 commit comments

Comments
 (0)