File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,16 @@ extension ALBTargetGroupRequest {
2020
2121 /// Return an `HTTPRequest` for this `ALBTargetGroupRequest`
2222 public func httpRequest( ) throws -> HTTPRequest {
23- HTTPRequest (
23+ let headers = self . headers ?? [ : ]
24+ let scheme = headers. first { $0. key. lowercased ( ) == " x-forwarded-proto " } ? . value
25+ let authority = headers. first { $0. key. lowercased ( ) == " host " } ? . value
26+
27+ return HTTPRequest (
2428 method: self . httpMethod,
25- scheme: self . headers ? [ " X-Forwarded-Proto " ] ,
26- authority: self . headers ? [ " Host " ] ,
29+ scheme: scheme ,
30+ authority: authority ,
2731 path: self . path,
28- headerFields: self . headers? . httpFields ( ) ?? [ : ]
32+ headerFields: headers. httpFields ( )
2933 )
3034 }
3135}
Original file line number Diff line number Diff line change @@ -111,8 +111,8 @@ struct ALBConversionTests {
111111
112112 let httpRequest = try albRequest. httpRequest ( )
113113
114- #expect( httpRequest. scheme == nil )
115- #expect( httpRequest. authority == nil )
114+ #expect( httpRequest. scheme == " https " )
115+ #expect( httpRequest. authority == " lambda-alb-123578498.us-east-1.elb.amazonaws.com " )
116116 }
117117
118118 @Test ( " HTTPResponse to ALB response conversion " )
You can’t perform that action at this time.
0 commit comments