@@ -94,7 +94,6 @@ def __call__(self, event: dict, context: "LambdaContext") -> dict:
9494 scope = self .event_to_asgi_scope (event )
9595 scope ["aws.event" ] = event
9696 scope ["aws.context" ] = context
97-
9897 http_cycle = HTTPCycle (scope , text_mime_types = self .text_mime_types )
9998
10099 initial_body = self .event_to_request_body (event )
@@ -103,6 +102,7 @@ def __call__(self, event: dict, context: "LambdaContext") -> dict:
103102 return response
104103
105104 def event_to_request_body (self , event : dict ) -> bytes :
105+ """Extracts request body from a Lambda event."""
106106 is_binary = event .get ("isBase64Encoded" , False )
107107 initial_body = event .get ("body" ) or b""
108108 if is_binary :
@@ -113,6 +113,15 @@ def event_to_request_body(self, event: dict) -> bytes:
113113 return initial_body
114114
115115 def event_to_asgi_scope (self , event : dict ) -> Scope :
116+ """Creates a scope object according to ASGI specification from a Lambda Event.
117+
118+ https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
119+
120+ Event comes from various sources: AWS ALB, AWS API Gateway of different
121+ versions and configurations(multivalue header, etc).
122+ Thus some heuristics is applied to guess event type.
123+
124+ """
116125 request_context = event ["requestContext" ]
117126
118127 if event .get ("multiValueHeaders" ):
0 commit comments