Skip to content

Commit e2170ec

Browse files
Override _read_body to allow max size to be read.
1 parent fe0a6e3 commit e2170ec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tabpy/tabpy_server/app/app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
UploadDestinationHandler,
2828
)
2929
import tornado
30+
from tornado.http1connection import HTTP1Connection
3031
import tabpy.tabpy_server.app.arrow_server as pa
3132
import _thread
3233

@@ -497,3 +498,16 @@ def _build_tabpy_state(self):
497498
logger.info(f"Loading state from state file {state_file_path}")
498499
tabpy_state = _get_state_from_file(state_file_dir)
499500
return tabpy_state, TabPyState(config=tabpy_state, settings=self.settings)
501+
502+
503+
# Override _read_body to allow content with size exceeding max_body_size
504+
# This enables proper handling of 413 errors in base_handler
505+
def _read_body_allow_max_size(self, code, headers, delegate):
506+
if "Content-Length" in headers:
507+
content_length = int(headers["Content-Length"])
508+
if content_length > self._max_body_size:
509+
return
510+
return self.original_read_body(code, headers, delegate)
511+
512+
HTTP1Connection.original_read_body = HTTP1Connection._read_body
513+
HTTP1Connection._read_body = _read_body_allow_max_size

0 commit comments

Comments
 (0)