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 @@ -177,9 +177,9 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayHttpA
connectionFeatures.RemoteIpAddress = remoteIpAddress;
}

if (apiGatewayRequest?.Headers?.ContainsKey("X-Forwarded-Port") == true)
if (apiGatewayRequest?.Headers?.TryGetValue("X-Forwarded-Port", out var port) == true)
{
connectionFeatures.RemotePort = int.Parse(apiGatewayRequest.Headers["X-Forwarded-Port"]);
connectionFeatures.RemotePort = int.Parse(port, CultureInfo.InvariantCulture);
}

// Call consumers customize method in case they want to change how API Gateway's request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy
requestFeatures.Method = apiGatewayRequest.HttpMethod;

string path = null;
if (apiGatewayRequest.PathParameters != null && apiGatewayRequest.PathParameters.ContainsKey("proxy") &&
if (apiGatewayRequest.PathParameters != null && apiGatewayRequest.PathParameters.TryGetValue("proxy", out var proxy) &&
!string.IsNullOrEmpty(apiGatewayRequest.Resource))
{
var proxyPath = apiGatewayRequest.PathParameters["proxy"];
var proxyPath = proxy;
path = apiGatewayRequest.Resource.Replace("{proxy+}", proxyPath);
}

Expand Down Expand Up @@ -242,9 +242,9 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy
connectionFeatures.RemoteIpAddress = remoteIpAddress;
}

if (apiGatewayRequest?.Headers?.ContainsKey("X-Forwarded-Port") == true)
if (apiGatewayRequest?.Headers?.TryGetValue("X-Forwarded-Port", out var forwardedPort) == true)
{
connectionFeatures.RemotePort = int.Parse(apiGatewayRequest.Headers["X-Forwarded-Port"]);
connectionFeatures.RemotePort = int.Parse(forwardedPort, CultureInfo.InvariantCulture);
}

// Call consumers customize method in case they want to change how API Gateway's request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ public ResponseContentEncoding GetResponseContentEncodingForContentType(string c
// ASP.NET Core will typically return content type with encoding like this "application/json; charset=utf-8"
// To find the content type in the dictionary we need to strip the encoding off.
var contentTypeWithoutEncoding = contentType.Split(';')[0].Trim();
if (_responseContentEncodingForContentType.ContainsKey(contentTypeWithoutEncoding))
if (_responseContentEncodingForContentType.TryGetValue(contentTypeWithoutEncoding, out var encoding))
{
return _responseContentEncodingForContentType[contentTypeWithoutEncoding];
return encoding;
}

return DefaultResponseContentEncoding;
Expand All @@ -391,9 +391,9 @@ public ResponseContentEncoding GetResponseContentEncodingForContentEncoding(stri
return DefaultResponseContentEncoding;
}

if (_responseContentEncodingForContentEncoding.ContainsKey(contentEncoding))
if (_responseContentEncodingForContentEncoding.TryGetValue(contentEncoding, out var encoding))
{
return _responseContentEncodingForContentEncoding[contentEncoding];
return encoding;
}

return DefaultResponseContentEncoding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected override void MarshallRequest(InvokeFeatures features, ApplicationLoad
var remotePort = GetSingleHeaderValue(lambdaRequest, "x-forwarded-port");
if (!string.IsNullOrEmpty(remotePort))
{
connectionFeatures.RemotePort = int.Parse(remotePort);
connectionFeatures.RemotePort = int.Parse(remotePort, CultureInfo.InvariantCulture);
}

// Call consumers customize method in case they want to change how API Gateway's request
Expand Down