Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy

requestFeatures.Path = Utilities.DecodeResourcePath(requestFeatures.Path);

requestFeatures.QueryString = Utilities.CreateQueryStringParamaters(
requestFeatures.QueryString = Utilities.CreateQueryStringParameters(
apiGatewayRequest.QueryStringParameters, apiGatewayRequest.MultiValueQueryStringParameters);

Utilities.SetHeadersCollection(requestFeatures.Headers, apiGatewayRequest.Headers, apiGatewayRequest.MultiValueHeaders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ namespace Amazon.Lambda.AspNetCoreServer
/// <typeparam name ="TStartup">The type containing the startup methods for the application.</typeparam>
public abstract class APIGatewayProxyFunction<TStartup> : APIGatewayProxyFunction where TStartup : class
{
/// <summary>
/// Default Constructor. The ASP.NET Core Framework will be initialized as part of the construction.
/// </summary>
protected APIGatewayProxyFunction()
: base()
{

}


/// <summary>
///
/// </summary>
/// <param name="startupMode">Configure when the ASP.NET Core framework will be initialized</param>
protected APIGatewayProxyFunction(StartupMode startupMode)
: base(startupMode)
{

}

/// <inheritdoc/>
protected override IWebHostBuilder CreateWebHostBuilder() =>
base.CreateWebHostBuilder().UseStartup<TStartup>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override void MarshallRequest(InvokeFeatures features, ApplicationLoad
requestFeatures.Method = lambdaRequest.HttpMethod;
requestFeatures.Path = Utilities.DecodeResourcePath(lambdaRequest.Path);

requestFeatures.QueryString = Utilities.CreateQueryStringParamaters(
requestFeatures.QueryString = Utilities.CreateQueryStringParameters(
lambdaRequest.QueryStringParameters, lambdaRequest.MultiValueQueryStringParameters);

Utilities.SetHeadersCollection(requestFeatures.Headers, lambdaRequest.Headers, lambdaRequest.MultiValueHeaders);
Expand Down
21 changes: 9 additions & 12 deletions Libraries/src/Amazon.Lambda.AspNetCoreServer/Internal/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal static (string body, bool isBase64Encoded) ConvertAspNetCoreBodyToLambd
}
}

internal static string CreateQueryStringParamaters(IDictionary<string, string> singleValues, IDictionary<string, IList<string>> multiValues)
internal static string CreateQueryStringParameters(IDictionary<string, string> singleValues, IDictionary<string, IList<string>> multiValues)
{
if (multiValues?.Count > 0)
{
Expand All @@ -78,7 +78,7 @@ internal static string CreateQueryStringParamaters(IDictionary<string, string> s
{
sb.Append("&");
}
sb.Append($"{kvp.Key}={value}");
sb.Append(kvp.Key).Append('=').Append(value);
}
}
return sb.ToString();
Expand All @@ -95,7 +95,7 @@ internal static string CreateQueryStringParamaters(IDictionary<string, string> s
{
sb.Append("&");
}
sb.Append($"{kvp.Key}={kvp.Value}");
sb.Append(kvp.Key).Append('=').Append(kvp.Value);
}
return sb.ToString();
}
Expand All @@ -120,16 +120,13 @@ internal static void SetHeadersCollection(IHeaderDictionary headers, IDictionary
headers[kvp.Key] = new StringValues(kvp.Value);
}
}

}

internal static string DecodeResourcePath(string resourcePath)
{
// Convert any + signs to percent encoding before url decoding the path.
resourcePath = resourcePath.Replace("+", "%2B");
resourcePath = resourcePath = WebUtility.UrlDecode(resourcePath);

return resourcePath;
}
internal static string DecodeResourcePath(string resourcePath) => WebUtility.UrlDecode(resourcePath
// Convert any + signs to percent encoding before URL decoding the path.
.Replace("+", "%2B")
// Double-escape any %2F (encoded / characters) so that they survive URL decoding the path.
.Replace("%2F", "%252F")
.Replace("%2f", "%252f"));
}
}