4747 SubscribeToTaskRequest ,
4848 TaskPushNotificationConfig ,
4949)
50- from a2a .utils .constants import (
51- DEFAULT_MAX_CONTENT_LENGTH ,
52- )
5350from a2a .utils .errors import (
5451 A2AError ,
5552 UnsupportedOperationError ,
@@ -202,7 +199,6 @@ def __init__( # noqa: PLR0913
202199 ]
203200 | None = None ,
204201 enable_v0_3_compat : bool = False ,
205- max_content_length : int | None = DEFAULT_MAX_CONTENT_LENGTH ,
206202 ) -> None :
207203 """Initializes the JsonRpcDispatcher.
208204
@@ -220,8 +216,6 @@ def __init__( # noqa: PLR0913
220216 extended_card_modifier: An optional callback to dynamically modify
221217 the extended agent card before it is served. It receives the
222218 call context.
223- max_content_length: The maximum allowed content length for incoming
224- requests. Defaults to 10MB. Set to None for unbounded maximum.
225219 enable_v0_3_compat: Whether to enable v0.3 backward compatibility on the same endpoint.
226220 """
227221 if not _package_starlette_installed :
@@ -242,7 +236,6 @@ def __init__( # noqa: PLR0913
242236 extended_card_modifier = extended_card_modifier ,
243237 )
244238 self ._context_builder = context_builder or DefaultCallContextBuilder ()
245- self ._max_content_length = max_content_length
246239 self .enable_v0_3_compat = enable_v0_3_compat
247240 self ._v03_adapter : JSONRPC03Adapter | None = None
248241
@@ -298,22 +291,6 @@ def _generate_error_response(
298291 status_code = 200 ,
299292 )
300293
301- def _allowed_content_length (self , request : Request ) -> bool :
302- """Checks if the request content length is within the allowed maximum.
303-
304- Args:
305- request: The incoming Starlette Request object.
306-
307- Returns:
308- False if the content length is larger than the allowed maximum, True otherwise.
309- """
310- if self ._max_content_length is not None :
311- with contextlib .suppress (ValueError ):
312- content_length = int (request .headers .get ('content-length' , '0' ))
313- if content_length and content_length > self ._max_content_length :
314- return False
315- return True
316-
317294 async def _handle_requests (self , request : Request ) -> Response : # noqa: PLR0911, PLR0912
318295 """Handles incoming POST requests to the main A2A endpoint.
319296
@@ -344,12 +321,6 @@ async def _handle_requests(self, request: Request) -> Response: # noqa: PLR0911
344321 request_id , str | int
345322 ):
346323 request_id = None
347- # Treat payloads lager than allowed as invalid request (-32600) before routing
348- if not self ._allowed_content_length (request ):
349- return self ._generate_error_response (
350- request_id ,
351- InvalidRequestError (message = 'Payload too large' ),
352- )
353324 logger .debug ('Request body: %s' , body )
354325 # 1) Validate base JSON-RPC structure only (-32600 on failure)
355326 try :
0 commit comments