Skip to content

Commit

Permalink
Add support for seekable wsgi.file_wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalresistor committed Jan 17, 2022
1 parent a91aca0 commit 2385762
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/waitress/buffers.py
Expand Up @@ -145,6 +145,16 @@ def __init__(self, file, block_size=32768):
self.file = file
self.block_size = block_size # for __iter__

# This is for the benefit of anyone that is attempting to wrap this
# wsgi.file_wrapper in a WSGI middleware and wants to seek, this is
# useful for instance for support Range requests
if _is_seekable(self.file):
if hasattr(self.file, "seekable"):
self.seekable = self.file.seekable

self.seek = self.file.seek
self.tell = self.file.tell

def prepare(self, size=None):
if _is_seekable(self.file):
start_pos = self.file.tell()
Expand Down

0 comments on commit 2385762

Please sign in to comment.