Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more unsignable headers #1231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/Private/CanonicalRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static class CanonicalRequest
"trailer",
"transfer-encoding",
"upgrade",
"user-agent",
"via",
"x-forwarded-for",
"x-forwarded-port",
"x-forwarded-proto",
Comment on lines +48 to +52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Gateway REST API (which uses CloudFront) always modifies "Via" and these three "X-Forwarded-*" headers. It also adds/modifies the "User-Agent" header if the incoming request doesn't have it or have it as an empty string.

HeaderKeys.XAmznTraceIdHeader
];

Expand Down
11 changes: 8 additions & 3 deletions test/Unit/Private/CanonicalRequestShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ public CanonicalRequestShould(TestSuiteContext context)
new[] { "TE", "gzip"},
new[] { "Trailer", "Expires"},
new[] { "Transfer-Encoding", "gzip"},
new[] { "Upgrade", "websocket"}
new[] { "Upgrade", "websocket"},
new[] { "User-Agent", "curl/7.64.1"},
new[] { "Via", "HTTP/1.1 my_proxy"},
new[] { "X-Forwarded-For", "203.0.113.195"},
new[] { "X-Forwarded-Port", "443"},
new[] { "X-Forwarded-Proto", "http"},
};


[Theory]
[InlineData("get-header-key-duplicate")]
Expand Down Expand Up @@ -261,7 +266,7 @@ internal static void AddUnsignableHeaders(HttpRequestMessage request)
foreach (var testCase in UnsignableHeadersTestCases)
{
var headerName = (string)testCase[0];
var headerValue = (string)testCase[0];
var headerValue = (string)testCase[1];

// Exclude the following headers due to them failing
if (headerValue is "Range" or "Transfer-Encoding")
Expand Down