From e8bef24c7f198134b439c7f51b82337660d46c9c Mon Sep 17 00:00:00 2001 From: Hans van Bakel Date: Sun, 12 May 2019 14:19:24 -0700 Subject: [PATCH 1/2] Fix for #458 --- .../APIGatewayProxyFunction.cs | 5 +++++ .../ApplicationLoadBalancerFunction.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs index 357dd72ef..025a9d21c 100644 --- a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs @@ -140,6 +140,11 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy requestFeatures.Scheme = "https"; requestFeatures.Method = apiGatewayRequest.HttpMethod; + if (string.IsNullOrWhiteSpace(apiGatewayRequest.RequestContext?.DomainName)) + { + _logger.LogWarning($"Request does not contain domain name information but is derived from {nameof(APIGatewayProxyFunction)}."); + } + string path = null; if (apiGatewayRequest.PathParameters != null && apiGatewayRequest.PathParameters.ContainsKey("proxy") && !string.IsNullOrEmpty(apiGatewayRequest.Resource)) diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs index 91b4f1ac8..306c7589e 100644 --- a/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs @@ -52,6 +52,11 @@ protected override void MarshallRequest(InvokeFeatures features, ApplicationLoad throw new Exception("Unable to determine header mode, single or multi value, because both Headers and MultiValueHeaders are null."); } + if (lambdaRequest.RequestContext?.Elb?.TargetGroupArn == null) + { + _logger.LogWarning($"Request does not contain ELB information but is derived from {nameof(ApplicationLoadBalancerFunction)}."); + } + // Look to see if the request is using mutli value headers or not. This is important when // marshalling the response to know whether to fill in the the Headers or MultiValueHeaders collection. // Since a Lambda function compute environment is only one processing one event at a time it is safe to store From 9bdab1d2d7c1545433a25d18308f13b56232ec88 Mon Sep 17 00:00:00 2001 From: Hans van Bakel Date: Sun, 12 May 2019 14:22:02 -0700 Subject: [PATCH 2/2] whitespace --- .../APIGatewayProxyFunction.cs | 8 ++++---- .../ApplicationLoadBalancerFunction.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs index 025a9d21c..b6c5c7c96 100644 --- a/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/APIGatewayProxyFunction.cs @@ -140,10 +140,10 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy requestFeatures.Scheme = "https"; requestFeatures.Method = apiGatewayRequest.HttpMethod; - if (string.IsNullOrWhiteSpace(apiGatewayRequest.RequestContext?.DomainName)) - { - _logger.LogWarning($"Request does not contain domain name information but is derived from {nameof(APIGatewayProxyFunction)}."); - } + if (string.IsNullOrWhiteSpace(apiGatewayRequest.RequestContext?.DomainName)) + { + _logger.LogWarning($"Request does not contain domain name information but is derived from {nameof(APIGatewayProxyFunction)}."); + } string path = null; if (apiGatewayRequest.PathParameters != null && apiGatewayRequest.PathParameters.ContainsKey("proxy") && diff --git a/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs b/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs index 306c7589e..ceccc7b37 100644 --- a/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs +++ b/Libraries/src/Amazon.Lambda.AspNetCoreServer/ApplicationLoadBalancerFunction.cs @@ -52,10 +52,10 @@ protected override void MarshallRequest(InvokeFeatures features, ApplicationLoad throw new Exception("Unable to determine header mode, single or multi value, because both Headers and MultiValueHeaders are null."); } - if (lambdaRequest.RequestContext?.Elb?.TargetGroupArn == null) - { - _logger.LogWarning($"Request does not contain ELB information but is derived from {nameof(ApplicationLoadBalancerFunction)}."); - } + if (lambdaRequest.RequestContext?.Elb?.TargetGroupArn == null) + { + _logger.LogWarning($"Request does not contain ELB information but is derived from {nameof(ApplicationLoadBalancerFunction)}."); + } // Look to see if the request is using mutli value headers or not. This is important when // marshalling the response to know whether to fill in the the Headers or MultiValueHeaders collection.