Skip to content

Commit

Permalink
Use bounded_stream for decompressor middleware
Browse files Browse the repository at this point in the history
The behaviour of the `bounded_stream` property is stable among different
WSGI servers while the `stream` property might behave differently (see
https://falcon.readthedocs.io/en/stable/api/request_and_response_wsgi.html#falcon.Request.bounded_stream).
  • Loading branch information
8R0WNI3 committed May 13, 2024
1 parent f87b655 commit e791f7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middleware/decompressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def process_resource(self, req: falcon.Request, resp: falcon.Response, resource,
if content_encoding == http_requests.EncodingMethod.GZIP:
try:
decompressor = zlib.decompressobj(wbits=31)
data = decompressor.decompress(req.stream.read())
data = decompressor.decompress(req.bounded_stream.read())
except Exception as e:
raise falcon.HTTPBadRequest(
title='Invalid gzip data',
Expand Down

0 comments on commit e791f7b

Please sign in to comment.