Skip to content

Commit

Permalink
refactor http request handlers (#179)
Browse files Browse the repository at this point in the history
* Use web universal fetch handler and stream collector

Correspond to aws/aws-sdk-js-v3#1123

* move runtime-specific stream collectors to individual request handler package
  • Loading branch information
AllanZhengYP authored May 18, 2020
1 parent 96a235f commit 2dccabd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ final class RuntimeConfigGenerator {
writer.write("bodyLengthChecker: calculateBodyLength,");
},
"streamCollector", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_NODE);
writer.addDependency(TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER);
writer.addImport("streamCollector", "streamCollector",
TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_NODE.packageName);
TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER.packageName);
writer.write("streamCollector,");
},
"base64Decoder", writer -> {
Expand Down Expand Up @@ -130,9 +130,9 @@ final class RuntimeConfigGenerator {
writer.write("bodyLengthChecker: calculateBodyLength,");
},
"streamCollector", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_BROWSER);
writer.addDependency(TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER);
writer.addImport("streamCollector", "streamCollector",
TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_BROWSER.packageName);
TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER.packageName);
writer.write("streamCollector,");
},
"base64Decoder", writer -> {
Expand Down Expand Up @@ -169,12 +169,6 @@ final class RuntimeConfigGenerator {
}
);
private final Map<String, Consumer<TypeScriptWriter>> reactNativeRuntimeConfigDefaults = MapUtils.of(
"requestHandler", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER);
writer.addImport("FetchHttpHandler", "FetchHttpHandler",
TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER.packageName);
writer.write("requestHandler: new FetchHttpHandler({ bufferBody: true }),");
},
"sha256", writer -> {
writer.addDependency(TypeScriptDependency.AWS_CRYPTO_SHA256_JS);
writer.addImport("Sha256", "Sha256",
Expand All @@ -187,12 +181,6 @@ final class RuntimeConfigGenerator {
TypeScriptDependency.AWS_SDK_URL_PARSER_NODE.packageName);
writer.write("urlParser: parseUrl,");
},
"streamCollector", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_RN);
writer.addImport("streamCollector", "streamCollector",
TypeScriptDependency.AWS_SDK_STREAM_COLLECTOR_RN.packageName);
writer.write("streamCollector,");
},
"defaultUserAgent", writer -> {
writer.addImport("name", "name", "./package.json");
writer.addImport("version", "version", "./package.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public enum TypeScriptDependency implements SymbolDependencyContainer {
AWS_CRYPTO_SHA256_JS("dependencies", "@aws-crypto/sha256-js", "^1.0.0-alpha.0", true),
AWS_SDK_HASH_NODE("dependencies", "@aws-sdk/hash-node", "^1.0.0-beta.0", true),

AWS_SDK_STREAM_COLLECTOR_NODE("dependencies", "@aws-sdk/stream-collector-node", "^1.0.0-beta.0", true),
AWS_SDK_STREAM_COLLECTOR_BROWSER("dependencies", "@aws-sdk/stream-collector-browser", "^1.0.0-beta.0", true),
AWS_SDK_STREAM_COLLECTOR_RN("dependencies", "@aws-sdk/stream-collector-native", "^1.0.0-beta.0", true),

AWS_SDK_URL_PARSER_BROWSER("dependencies", "@aws-sdk/url-parser-browser", "^1.0.0-beta.0", true),
AWS_SDK_URL_PARSER_NODE("dependencies", "@aws-sdk/url-parser-node", "^1.0.0-beta.0", true),

Expand Down

0 comments on commit 2dccabd

Please sign in to comment.