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

fix(clients): lowercase all header names in serializer #1892

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

AllanZhengYP
Copy link
Contributor

The HTTP request class doesn't have any implementations to insure
case-insensitivity of the http headers. So we need to be mindful
when populating these headers. Otherwise, the reqeust signature
will be messed up. This change will ensure the protocol-specific
default headers like content-type will be overriden by the serialized
header if exists.

For other headers added through middleware stack either by
customization or users, it wouldn't affect signing or sending as long
as the request doesn't contain same header names in different casing.
All the internal headers will be consistent. But users should be
careful when they are adding their own headers.

We don't add middleware to lowercase all headers to prevent
alternating the users' customizations.

Fixes: #1800

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

trivikr
trivikr previously approved these changes Jan 8, 2021
@codecov-io
Copy link

Codecov Report

Merging #1892 (a6d4ba6) into master (f2a47e8) will increase coverage by 0.52%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1892      +/-   ##
==========================================
+ Coverage   79.30%   79.83%   +0.52%     
==========================================
  Files         368      368              
  Lines       15132    15543     +411     
  Branches     3222     3364     +142     
==========================================
+ Hits        12001    12409     +408     
- Misses       3131     3134       +3     
Impacted Files Coverage Δ
packages/util-waiter/src/utils/validate.ts 81.81% <0.00%> (-18.19%) ⬇️
lib/storage/src/data-chunk/readable-helper.ts 88.23% <0.00%> (-4.08%) ⬇️
packages/util-dynamodb/src/convertToAttr.ts 98.70% <0.00%> (-1.30%) ⬇️
packages/util-waiter/src/waiter.ts 100.00% <0.00%> (ø)
protocol_tests/aws-ec2/endpoints.ts 81.48% <0.00%> (ø)
protocol_tests/aws-json/endpoints.ts 81.48% <0.00%> (ø)
protocol_tests/aws-query/endpoints.ts 81.48% <0.00%> (ø)
packages/util-dynamodb/src/marshall.ts 100.00% <0.00%> (ø)
protocol_tests/aws-restxml/endpoints.ts 81.48% <0.00%> (ø)
protocol_tests/aws-restjson/endpoints.ts 81.48% <0.00%> (ø)
... and 140 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4c302b...a6d4ba6. Read the comment docs.

@trivikr trivikr self-requested a review January 8, 2021 19:54
@trivikr trivikr dismissed their stale review January 8, 2021 19:56

CI failed, protocol_tests need to be updated

The HTTP request class doesn't have any implementations to insure
case-insensitivity of the http headers. So we need to be mindful
when populating these headers. Otherwise, the reqeust signature
will be messed up. This change will ensure the protocol-specific
default headers like content-type will be overriden by the serialized
header if exists.

For other headers added through middleware stack either by
customization or users, it wouldn't affect signing or sending as long
as the request doesn't contain same header names in different casing.
All the internal headers will be consistent. But users should be
careful when they are adding their own headers.

We don't add middleware to lowercase all headers to prevent
alternating the users' customizations.

Ref: aws#1800
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 657c5c2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@AllanZhengYP
Copy link
Contributor Author

Integration test is confirmed to pass:

yarn test:integration-legacy
yarn run v1.22.5
$ cucumber-js --fail-fast
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

152 scenarios (152 passed)
528 steps (528 passed)
2m57.222s
Done in 181.85s.

/cc @kstich

@AllanZhengYP AllanZhengYP merged commit 1308721 into aws:master Jan 13, 2021
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SignatureDoesNotMatch while uploading an object to S3 with ContentType
5 participants