Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should prefer the request ID from the standard header", () => {
expect(
extractMetadata(new HttpResponse({
...httpResponseOptions,
headers: {
"X-Amz-Request-ID": "id",
"X-Amz-RequestId": "alt_id"
}
})).requestId
).toBe("id");
});
it("should extract and downcase headers", () => {
const response = new HttpResponse(httpResponseOptions);
expect(extractMetadata(response).httpHeaders).toEqual({
foo: response.headers.Foo,
fizz: response.headers.Fizz,
snap: response.headers.Snap
});
});
it("should extract the status code from responses", () => {
const response = new HttpResponse(httpResponseOptions);
expect(extractMetadata(response).httpStatusCode).toBe(response.statusCode);
});
req.on("response", headers => {
const httpResponse = new HttpResponse({
statusCode: headers[":status"] || -1,
headers: getTransformedHeaders(headers),
body: req
});
resolve({ response: httpResponse });
});
const req = (isSSL ? https : http).request(nodeHttpsOptions, res => {
const httpResponse = new HttpResponse({
statusCode: res.statusCode || -1,
headers: getTransformedHeaders(res.headers),
body: res
});
resolve({ response: httpResponse });
});