Skip to content

Commit a2128ae

Browse files
Check if max_request_size is set.
1 parent e35346f commit a2128ae

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tabpy/tabpy_server/handlers/base_handler.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,17 +453,15 @@ def request_body_size_within_limit(self):
453453
bool
454454
True if the request body size is within the limit, False otherwise.
455455
"""
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=f"Request with size {content_length} exceeded limit of {self.max_request_size} (bytes).",
466-
)
467-
return False
468-
456+
if self.max_request_size is not None:
457+
if "Content-Length" in self.request.headers:
458+
content_length = int(self.request.headers["Content-Length"])
459+
if content_length > self.max_request_size:
460+
self.error_out(
461+
413,
462+
info="Request Entity Too Large",
463+
log_message=f"Request with size {content_length} exceeded limit of {self.max_request_size} (bytes).",
464+
)
465+
return False
466+
469467
return True

0 commit comments

Comments
 (0)