File tree 2 files changed +4
-1
lines changed
2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -171,10 +171,12 @@ def send_file(
171
171
self ,
172
172
filename : str = "index.html" ,
173
173
root_path : str = "./" ,
174
+ buffer_size : int = 1024 ,
174
175
) -> None :
175
176
"""
176
177
Send response with content of ``filename`` located in ``root_path``.
177
178
Implicitly calls ``_send_headers`` before sending the file content.
179
+ File is send split into ``buffer_size`` parts.
178
180
179
181
Should be called **only once** per response.
180
182
"""
@@ -196,7 +198,7 @@ def send_file(
196
198
)
197
199
198
200
with open (root_path + filename , "rb" ) as file :
199
- while bytes_read := file .read (2048 ):
201
+ while bytes_read := file .read (buffer_size ):
200
202
self ._send_bytes (self .request .connection , bytes_read )
201
203
self ._response_already_sent = True
202
204
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ def poll(self):
172
172
HTTPResponse (request ).send_file (
173
173
filename = request .path ,
174
174
root_path = self .root_path ,
175
+ buffer_size = self .request_buffer_size ,
175
176
)
176
177
else :
177
178
HTTPResponse (
You can’t perform that action at this time.
0 commit comments