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

feat: refactor http request handlers #1186

Merged
merged 7 commits into from
May 18, 2020

Conversation

AllanZhengYP
Copy link
Contributor

@AllanZhengYP AllanZhengYP commented May 14, 2020

Replaces: #1123
Resolves: #1107

Changes are made in the PR:

  1. Previously, browsers' fetch-http-handler relies on the assumption that Response.body is a ReadableStream. This is not true for older desktop and mobile browsers. The previous design partially addresses this issue by explicitly notify fetch-http-handler to return body payload inblob instead of ReadableStream in ReactNative where ReadableStream is not available. But this solution doesn't solve proplems in old desktop browsers and IE.

    In this PR, the fetch-http-handler will dynamicly return body payload in blob or ReadableStream base on whether Response.body is implemented. This solution return streaming payload data when it's available. It's also flexible as it will return streaming data if user supply a web stream polyfill.

  2. Because we will use universal fetch handler in both browsers and ReactNative, we also merge the stream-collector-browser and stream-collector-native into a single stream-collector-web, which will collect the stream if payload's streaming, or convert the payload blob to binary data. This package is merged into fetch-http-handler. See next point for more information.

  3. According to refactor: Support all the webs #1123 (comment), I move the stream-collector-web into fetch-http-handler and move stream-collector-node into node-http-handler because stream collector and request handler are intertwined with each other. It would prevent people incorrectly use node stream collector with browser request handler. Moreover, the 2 components will live in the same module but are different interfaces. So we can still introduce non-http handler without a stream collector in the future

/cc @russell-dot-js

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

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 2caab47
  • 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:

AWS_PROFILE=js-sdk-team yarn test:integration
yarn run v1.22.1
$ cucumber-js --fail-fast
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

153 scenarios (153 passed)
534 steps (534 passed)
1m45.891s
Done in 109.77s.

@AllanZhengYP
Copy link
Contributor Author

✅ReactNative iOS testing S3.listObjects

expand to see the screen shot

Simulator Screen Shot - iPhone X - 2020-05-14 at 16 50 13

@AllanZhengYP AllanZhengYP requested a review from trivikr May 14, 2020 23:54
@codecov-io
Copy link

codecov-io commented May 15, 2020

Codecov Report

Merging #1186 into master will decrease coverage by 0.23%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1186      +/-   ##
==========================================
- Coverage   73.33%   73.09%   -0.24%     
==========================================
  Files         285      286       +1     
  Lines       12399    12408       +9     
  Branches     2892     2898       +6     
==========================================
- Hits         9093     9070      -23     
- Misses       3306     3338      +32     
Impacted Files Coverage Δ
protocol_tests/aws-json/protocols/Aws_json1_1.ts 66.04% <0.00%> (-0.62%) ⬇️
...ol_tests/aws-restjson/protocols/Aws_restJson1_1.ts 62.04% <0.00%> (-0.11%) ⬇️
protocol_tests/aws-query/protocols/Aws_query.ts 68.60% <0.00%> (-0.11%) ⬇️
...rotocol_tests/aws-restxml/protocols/Aws_restXml.ts 67.23% <0.00%> (-0.07%) ⬇️
protocol_tests/aws-ec2/protocols/Aws_ec2.ts 63.56% <0.00%> (-0.04%) ⬇️
clients/client-s3/runtimeConfig.ts 100.00% <0.00%> (ø)
packages/node-http-handler/src/index.ts 100.00% <0.00%> (ø)
protocol_tests/aws-ec2/runtimeConfig.ts 100.00% <0.00%> (ø)
packages/fetch-http-handler/src/index.ts 100.00% <0.00%> (ø)
protocol_tests/aws-json/runtimeConfig.ts 100.00% <0.00%> (ø)
... and 11 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 117e9ca...0d60066. Read the comment docs.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

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

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

@AllanZhengYP AllanZhengYP changed the title [Updated] Support all the browsers feat: refactor http request handlers May 15, 2020
Copy link
Contributor

@alexforsyth alexforsyth left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@trivikr trivikr left a comment

Choose a reason for hiding this comment

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

LGTM, just one nit to remove console.log used while debugging

packages/fetch-http-handler/src/fetch-http-handler.spec.ts Outdated Show resolved Hide resolved
Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

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

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

Copy link
Contributor

@russell-dot-js russell-dot-js left a comment

Choose a reason for hiding this comment

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

🤑 🤑 🤑

@AllanZhengYP AllanZhengYP merged commit 605ebc5 into aws:master May 18, 2020
@Stereobit
Copy link

Thanks for this @AllanFly120 @russell-dot-js !

@russell-dot-js
Copy link
Contributor

@AllanFly120 now that this is merged, how do we get a new release cut?
Also, for curiosity's sake, can you point out what changes you had to make for the codegen to properly generate the new clients?

@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 20, 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.

packages/stream-collector-browser not compatible with Edge/IE11/Older versions of android
7 participants