mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-03 11:11:30 +08:00
fix: use smaller buffer in finish_body for faster timeout
Reduce buffer size from 8192 to 1024 bytes when discarding unread body data, allowing timeouts to trigger more quickly on slow or stalled connections.
This commit is contained in:
parent
66963367f3
commit
f95ac41b8f
@ -36,9 +36,9 @@ class Parser:
|
||||
"""
|
||||
if self.mesg:
|
||||
try:
|
||||
data = self.mesg.body.read(8192)
|
||||
data = self.mesg.body.read(1024)
|
||||
while data:
|
||||
data = self.mesg.body.read(8192)
|
||||
data = self.mesg.body.read(1024)
|
||||
except ssl.SSLWantReadError:
|
||||
# SSL socket has no more application data available
|
||||
pass
|
||||
|
||||
@ -1443,7 +1443,7 @@ class TestFinishBodySSL:
|
||||
parser.finish_body() # Should not raise
|
||||
|
||||
# Verify body.read was called
|
||||
mock_body.read.assert_called_once_with(8192)
|
||||
mock_body.read.assert_called_once_with(1024)
|
||||
|
||||
def test_finish_body_reads_all_data_before_ssl_error(self):
|
||||
"""Test that finish_body() reads all available data before SSLWantReadError."""
|
||||
@ -1513,4 +1513,4 @@ class TestFinishBodySSL:
|
||||
parser.finish_body()
|
||||
|
||||
# Verify body.read was called once and returned empty
|
||||
mock_body.read.assert_called_once_with(8192)
|
||||
mock_body.read.assert_called_once_with(1024)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user