@@ -372,3 +372,40 @@ async def app(scope, receive, send):
372372 "headers" : {"content-type" : content_type .decode ()},
373373 "body" : utf_res_body ,
374374 }
375+
376+
377+ @pytest .mark .parametrize ("multi_value_headers_enabled" , (True , False ))
378+ def test_aws_alb_exclude_headers (multi_value_headers_enabled ) -> None :
379+ async def app (scope , receive , send ):
380+ await send (
381+ {
382+ "type" : "http.response.start" ,
383+ "status" : 200 ,
384+ "headers" : [
385+ [b"content-type" , b"text/plain; charset=utf-8" ],
386+ [b"x-custom-header" , b"test" ],
387+ ],
388+ }
389+ )
390+ await send ({"type" : "http.response.body" , "body" : b"Hello, world!" })
391+
392+ handler = Mangum (app , lifespan = "off" , exclude_headers = ["x-custom-header" ])
393+ event = get_mock_aws_alb_event (
394+ "GET" , "/test" , {}, None , None , False , multi_value_headers_enabled
395+ )
396+ response = handler (event , {})
397+
398+ expected_response = {
399+ "statusCode" : 200 ,
400+ "isBase64Encoded" : False ,
401+ "body" : "Hello, world!" ,
402+ }
403+ if multi_value_headers_enabled :
404+ expected_response ["multiValueHeaders" ] = {
405+ "content-type" : ["text/plain; charset=utf-8" ],
406+ }
407+ else :
408+ expected_response ["headers" ] = {
409+ "content-type" : "text/plain; charset=utf-8" ,
410+ }
411+ assert response == expected_response
0 commit comments