File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
tabpy/tabpy_server/handlers Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ def initialize(self, app):
127
127
self .username = None
128
128
self .password = None
129
129
self .eval_timeout = self .settings [SettingsParameters .EvaluateTimeout ]
130
+ self .max_request_size = app .max_request_size
130
131
131
132
self .logger = ContextLoggerWrapper (self .request )
132
133
self .logger .enable_context_logging (
@@ -442,3 +443,27 @@ def fail_with_auth_error(self):
442
443
info = "Not Acceptable" ,
443
444
log_message = "Username or password provided when authentication not available." ,
444
445
)
446
+
447
+ def request_body_size_within_limit (self ):
448
+ """
449
+ Determines if the request body size is within the specified limit.
450
+
451
+ Returns
452
+ -------
453
+ bool
454
+ True if the request body size is within the limit, False otherwise.
455
+ """
456
+ headers = self .request .headers
457
+
458
+ if "Content-Length" in headers :
459
+ content_length = int (headers ["Content-Length" ])
460
+
461
+ if content_length > self .max_request_size :
462
+ self .error_out (
463
+ 413 ,
464
+ info = "Request Entity Too Large" ,
465
+ log_message = "Request body size exceeds the specified limit." ,
466
+ )
467
+ return False
468
+
469
+ return True
You can’t perform that action at this time.
0 commit comments