@@ -73,17 +73,16 @@ def asm_start_request(
7373 route : Optional [str ] = None
7474
7575 if event_source .event_type == EventTypes .ALB :
76- headers = event .get ("headers" )
77- multi_value_request_headers = event .get ("multiValueHeaders" )
78- if multi_value_request_headers :
79- request_headers = _to_single_value_headers (multi_value_request_headers )
80- else :
81- request_headers = headers or {}
82-
8376 raw_uri = event .get ("path" )
84- parsed_query = event .get ("multiValueQueryStringParameters" ) or event .get (
85- "queryStringParameters"
86- )
77+
78+ if event_source .subtype == EventSubtypes .ALB :
79+ request_headers = event .get ("headers" , {})
80+ parsed_query = event .get ("queryStringParameters" )
81+ if event_source .subtype == EventSubtypes .ALB_MULTI_VALUE_HEADERS :
82+ request_headers = _to_single_value_headers (
83+ event .get ("multiValueHeaders" , {})
84+ )
85+ parsed_query = event .get ("multiValueQueryStringParameters" )
8786
8887 elif event_source .event_type == EventTypes .LAMBDA_FUNCTION_URL :
8988 request_headers = event .get ("headers" , {})
@@ -226,15 +225,27 @@ def get_asm_blocked_response(
226225 content_type = blocked .get ("content-type" , "application/json" )
227226 content = http_utils ._get_blocked_template (content_type )
228227
229- response_headers = {
230- "content-type" : content_type ,
231- }
232- if "location" in blocked :
233- response_headers ["location" ] = blocked ["location" ]
234-
235- return {
228+ response = {
236229 "statusCode" : blocked .get ("status_code" , 403 ),
237- "headers" : response_headers ,
238230 "body" : content ,
239231 "isBase64Encoded" : False ,
240232 }
233+
234+ needs_multi_value_headers = event_source .equals (
235+ EventTypes .ALB , EventSubtypes .ALB_MULTI_VALUE_HEADERS
236+ )
237+
238+ if needs_multi_value_headers :
239+ response ["multiValueHeaders" ] = {
240+ "content-type" : [content_type ],
241+ }
242+ if "location" in blocked :
243+ response ["multiValueHeaders" ]["location" ] = [blocked ["location" ]]
244+ else :
245+ response ["headers" ] = {
246+ "content-type" : content_type ,
247+ }
248+ if "location" in blocked :
249+ response ["headers" ]["location" ] = blocked ["location" ]
250+
251+ return response
0 commit comments