Skip to content

Commit 0a2ff8e

Browse files
AllanZhengYPsrchase
authored andcommitted
chore: add updated RDS DATA smithy model (#370)
* chore: add http request type guard for middlewares header default middleware expect continue middleare * chore: add http request type guard for apply body checksum middlewares * chore: only build and test demo smithy client * feat: add isInstance to httpResponse * chore: update rds data model * chore: update to ts3.7; update rds model#3 * chore: update tsconfig to genenerte types only once * chore: update gitignore * chore: parse body with streamCollector * chore: add error deserialization * chore: stub Field union * fix: fix middleware-header-default test * fix: fix retry-middleware unit test
1 parent b1f11ff commit 0a2ff8e

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

packages/fetch-http-handler/src/fetch-http-handler.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FetchHttpHandler } from "./fetch-http-handler";
22
import { AbortController } from "@aws-sdk/abort-controller";
33
import * as timeouts from "./request-timeout";
4+
import { HttpRequest } from "@aws-sdk/protocol-http";
45

56
const mockRequest = jest.fn();
67
let mockResponse: any;
@@ -66,14 +67,14 @@ describe("httpHandler", () => {
6667

6768
(global as any).fetch = mockFetch;
6869

69-
let httpRequest = {
70+
let httpRequest = new HttpRequest({
7071
headers: {},
7172
hostname: "foo.amazonaws.com",
7273
method: "GET",
7374
path: "/test/?bar=baz",
7475
protocol: "https:",
7576
port: 443
76-
};
77+
});
7778
const fetchHttpHandler = new FetchHttpHandler();
7879

7980
let response = await fetchHttpHandler.handle(httpRequest, {});

packages/fetch-http-handler/src/fetch-http-handler.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import {
2-
HttpOptions,
3-
HeaderBag,
4-
HttpHandlerOptions,
5-
HttpRequest,
6-
HttpResponse
7-
} from "@aws-sdk/types";
8-
import { HttpHandler } from "@aws-sdk/protocol-http";
1+
import { HttpOptions, HeaderBag, HttpHandlerOptions } from "@aws-sdk/types";
2+
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
93
import { requestTimeout } from "./request-timeout";
104
import { buildQueryString } from "@aws-sdk/querystring-builder";
115

@@ -31,9 +25,9 @@ export class FetchHttpHandler implements HttpHandler {
3125
}
3226

3327
handle(
34-
request: HttpRequest<Blob>,
28+
request: HttpRequest,
3529
options: HttpHandlerOptions
36-
): Promise<{ response: HttpResponse<Blob> }> {
30+
): Promise<{ response: HttpResponse }> {
3731
const abortSignal = options && options.abortSignal;
3832
const requestTimeoutInMs = this.httpOptions.requestTimeout;
3933

@@ -78,12 +72,12 @@ export class FetchHttpHandler implements HttpHandler {
7872
transformedHeaders[pair[0]] = pair[1];
7973
}
8074

81-
return response.blob().then<{ response: HttpResponse<Blob> }>(body => ({
82-
response: {
75+
return response.blob().then<{ response: HttpResponse }>(body => ({
76+
response: new HttpResponse({
8377
headers: transformedHeaders,
8478
statusCode: response.status,
8579
body
86-
}
80+
})
8781
}));
8882
}),
8983
requestTimeout(requestTimeoutInMs)

packages/node-http-handler/src/node-http-handler.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AbortController } from "@aws-sdk/abort-controller";
2+
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
23
import { Server as HttpServer } from "http";
34
import { Server as HttpsServer } from "https";
45
import * as https from "https";
@@ -8,7 +9,6 @@ import { ReadFromBuffers } from "./readable.mock";
89
import {
910
createMockHttpServer,
1011
createMockHttpsServer,
11-
createContinueResponseFunction,
1212
createResponseFunction
1313
} from "./server.mock";
1414
import { AddressInfo } from "net";
@@ -38,14 +38,14 @@ describe("NodeHttpHandler", () => {
3838
const nodeHttpHandler = new NodeHttpHandler();
3939

4040
let { response } = await nodeHttpHandler.handle(
41-
{
41+
new HttpRequest({
4242
hostname: "localhost",
4343
method: "GET",
4444
port: (mockHttpServer.address() as AddressInfo).port,
4545
protocol: "http:",
4646
path: "/",
4747
headers: {}
48-
},
48+
}),
4949
{}
5050
);
5151

@@ -247,14 +247,14 @@ describe("NodeHttpHandler", () => {
247247

248248
await expect(
249249
nodeHttpHandler.handle(
250-
{
250+
new HttpRequest({
251251
hostname: "localhost",
252252
method: "GET",
253253
port: (mockHttpsServer.address() as AddressInfo).port,
254254
protocol: "fake:", // trigger a request error
255255
path: "/",
256256
headers: {}
257-
},
257+
}),
258258
{}
259259
)
260260
).rejects.toHaveProperty("message");
@@ -281,14 +281,14 @@ describe("NodeHttpHandler", () => {
281281

282282
await expect(
283283
nodeHttpHandler.handle(
284-
{
284+
new HttpRequest({
285285
hostname: "localhost",
286286
method: "GET",
287287
port: (mockHttpsServer.address() as AddressInfo).port,
288288
protocol: "https:",
289289
path: "/",
290290
headers: {}
291-
},
291+
}),
292292
{
293293
abortSignal: {
294294
aborted: true
@@ -331,14 +331,14 @@ describe("NodeHttpHandler", () => {
331331

332332
await expect(
333333
nodeHttpHandler.handle(
334-
{
334+
new HttpRequest({
335335
hostname: "localhost",
336336
method: "GET",
337337
port: (mockHttpsServer.address() as AddressInfo).port,
338338
protocol: "https:",
339339
path: "/",
340340
headers: {}
341-
},
341+
}),
342342
{
343343
abortSignal: abortController.signal
344344
}

packages/node-http-handler/src/node-http-handler.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ import * as https from "https";
22
import * as http from "http";
33
import { Readable } from "stream";
44
import { buildQueryString } from "@aws-sdk/querystring-builder";
5-
import {
6-
HeaderBag,
7-
HttpOptions,
8-
HttpRequest,
9-
HttpResponse,
10-
NodeHttpOptions
11-
} from "@aws-sdk/types";
12-
import { HttpHandler } from "@aws-sdk/protocol-http";
5+
import { HeaderBag, HttpOptions, NodeHttpOptions } from "@aws-sdk/types";
6+
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
137
import { setConnectionTimeout } from "./set-connection-timeout";
148
import { setSocketTimeout } from "./set-socket-timeout";
159
import { writeRequestBody } from "./write-request-body";
@@ -30,9 +24,9 @@ export class NodeHttpHandler implements HttpHandler {
3024
}
3125

3226
handle(
33-
request: HttpRequest<Readable>,
27+
request: HttpRequest,
3428
options: HttpOptions
35-
): Promise<{ response: HttpResponse<Readable> }> {
29+
): Promise<{ response: HttpResponse }> {
3630
// determine which http(s) client to use
3731
const isSSL = request.protocol === "https:";
3832
const httpClient = isSSL ? https : http;
@@ -78,11 +72,11 @@ export class NodeHttpHandler implements HttpHandler {
7872
: headerValues;
7973
}
8074

81-
const httpResponse: HttpResponse<Readable> = {
75+
const httpResponse = new HttpResponse({
8276
statusCode: res.statusCode || -1,
8377
headers: transformedHeaders,
8478
body: res
85-
};
79+
});
8680
resolve({ response: httpResponse });
8781
});
8882

0 commit comments

Comments
 (0)