Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/node-http-handler

Package Overview
Dependencies
Maintainers
4
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/node-http-handler - npm Package Compare versions

Comparing version 0.1.0-preview.8 to 1.0.0-alpha.1

build/get-transformed-headers.d.ts

1

build/index.d.ts
export * from "./node-http-handler";
export * from "./node-http2-handler";

5

build/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./node-http-handler"), exports);
//# sourceMappingURL=index.js.map
tslib_1.__exportStar(require("./node-http2-handler"), exports);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsOERBQW9DO0FBQ3BDLCtEQUFxQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gXCIuL25vZGUtaHR0cC1oYW5kbGVyXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9ub2RlLWh0dHAyLWhhbmRsZXJcIjtcbiJdfQ==
/// <reference types="node" />
import { Readable } from "stream";
import { HttpHandler, HttpHandlerOptions, HttpRequest, HttpResponse, NodeHttpOptions } from "@aws-sdk/types";
export declare class NodeHttpHandler implements HttpHandler<Readable, NodeHttpOptions> {
private readonly httpOptions;
import * as https from "https";
import * as http from "http";
import { HttpHandlerOptions } from "@aws-sdk/types";
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
/**
* Represents the http options that can be passed to a node http client.
*/
export interface NodeHttpOptions {
/**
* The maximum time in milliseconds that the connection phase of a request
* may take before the connection attempt is abandoned.
*/
connectionTimeout?: number;
/**
* The maximum time in milliseconds that a socket may remain idle before it
* is closed.
*/
socketTimeout?: number;
httpAgent?: http.Agent;
httpsAgent?: https.Agent;
}
export declare class NodeHttpHandler implements HttpHandler {
private readonly httpAgent;
private readonly httpsAgent;
constructor(httpOptions?: NodeHttpOptions);
private readonly connectionTimeout?;
private readonly socketTimeout?;
readonly metadata: {
handlerProtocol: string;
};
constructor({ connectionTimeout, socketTimeout, httpAgent, httpsAgent }?: NodeHttpOptions);
destroy(): void;
handle(request: HttpRequest<Readable>, options: HttpHandlerOptions): Promise<HttpResponse<Readable>>;
handle(request: HttpRequest, { abortSignal }: HttpHandlerOptions): Promise<{
response: HttpResponse;
}>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var https = require("https");
var http = require("http");
var querystring_builder_1 = require("@aws-sdk/querystring-builder");
var set_connection_timeout_1 = require("./set-connection-timeout");
var set_socket_timeout_1 = require("./set-socket-timeout");
var write_request_body_1 = require("./write-request-body");
var NodeHttpHandler = /** @class */ (function () {
function NodeHttpHandler(httpOptions) {
if (httpOptions === void 0) { httpOptions = {}; }
this.httpOptions = httpOptions;
var keepAlive = httpOptions.keepAlive;
this.httpAgent = new http.Agent({ keepAlive: keepAlive });
this.httpsAgent = new https.Agent({ keepAlive: keepAlive });
const https = require("https");
const http = require("http");
const querystring_builder_1 = require("@aws-sdk/querystring-builder");
const protocol_http_1 = require("@aws-sdk/protocol-http");
const set_connection_timeout_1 = require("./set-connection-timeout");
const set_socket_timeout_1 = require("./set-socket-timeout");
const write_request_body_1 = require("./write-request-body");
const get_transformed_headers_1 = require("./get-transformed-headers");
class NodeHttpHandler {
constructor({ connectionTimeout, socketTimeout, httpAgent, httpsAgent } = {}) {
// Node http handler is hard-coded to http/1.1: https://github.com/nodejs/node/blob/ff5664b83b89c55e4ab5d5f60068fb457f1f5872/lib/_http_server.js#L286
this.metadata = { handlerProtocol: "http/1.1" };
this.connectionTimeout = connectionTimeout;
this.socketTimeout = socketTimeout;
const keepAlive = true;
this.httpAgent = httpAgent || new http.Agent({ keepAlive });
this.httpsAgent = httpsAgent || new https.Agent({ keepAlive });
}
NodeHttpHandler.prototype.destroy = function () {
destroy() {
this.httpAgent.destroy();
this.httpsAgent.destroy();
};
NodeHttpHandler.prototype.handle = function (request, options) {
var _this = this;
// determine which http(s) client to use
var isSSL = request.protocol === "https:";
var httpClient = isSSL ? https : http;
var path = request.path;
if (request.query) {
var queryString = querystring_builder_1.buildQueryString(request.query);
if (queryString) {
path += "?" + queryString;
}
}
var nodeHttpsOptions = {
headers: request.headers,
host: request.hostname,
method: request.method,
path: path,
port: request.port,
agent: isSSL ? this.httpsAgent : this.httpAgent
};
return new Promise(function (resolve, reject) {
var abortSignal = options && options.abortSignal;
var _a = _this.httpOptions, connectionTimeout = _a.connectionTimeout, socketTimeout = _a.socketTimeout;
}
handle(request, { abortSignal }) {
return new Promise((resolve, reject) => {
// if the request was already aborted, prevent doing extra work
if (abortSignal && abortSignal.aborted) {
var abortError = new Error("Request aborted");
const abortError = new Error("Request aborted");
abortError.name = "AbortError";

@@ -52,40 +34,32 @@ reject(abortError);

}
// determine which http(s) client to use
const isSSL = request.protocol === "https:";
const queryString = querystring_builder_1.buildQueryString(request.query || {});
const nodeHttpsOptions = {
headers: request.headers,
host: request.hostname,
method: request.method,
path: queryString ? `${request.path}?${queryString}` : request.path,
port: request.port,
agent: isSSL ? this.httpsAgent : this.httpAgent
};
// create the http request
var req = httpClient.request(nodeHttpsOptions, function (res) {
var e_1, _a;
var httpHeaders = res.headers;
var transformedHeaders = {};
try {
for (var _b = tslib_1.__values(Object.keys(httpHeaders)), _c = _b.next(); !_c.done; _c = _b.next()) {
var name = _c.value;
var headerValues = httpHeaders[name];
transformedHeaders[name] = Array.isArray(headerValues)
? headerValues.join(",")
: headerValues;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
var httpResponse = {
const req = (isSSL ? https : http).request(nodeHttpsOptions, res => {
const httpResponse = new protocol_http_1.HttpResponse({
statusCode: res.statusCode || -1,
headers: transformedHeaders,
headers: get_transformed_headers_1.getTransformedHeaders(res.headers),
body: res
};
resolve(httpResponse);
});
resolve({ response: httpResponse });
});
req.on("error", reject);
// wire-up any timeout logic
set_connection_timeout_1.setConnectionTimeout(req, reject, connectionTimeout);
set_socket_timeout_1.setSocketTimeout(req, reject, socketTimeout);
set_connection_timeout_1.setConnectionTimeout(req, reject, this.connectionTimeout);
set_socket_timeout_1.setSocketTimeout(req, reject, this.socketTimeout);
// wire-up abort logic
if (abortSignal) {
abortSignal.onabort = function () {
abortSignal.onabort = () => {
// ensure request is destroyed
req.abort();
var abortError = new Error("Request aborted");
const abortError = new Error("Request aborted");
abortError.name = "AbortError";

@@ -97,6 +71,5 @@ reject(abortError);

});
};
return NodeHttpHandler;
}());
}
}
exports.NodeHttpHandler = NodeHttpHandler;
//# sourceMappingURL=node-http-handler.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZS1odHRwLWhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbm9kZS1odHRwLWhhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwrQkFBK0I7QUFDL0IsNkJBQTZCO0FBQzdCLHNFQUFnRTtBQUVoRSwwREFBZ0Y7QUFDaEYscUVBQWdFO0FBQ2hFLDZEQUF3RDtBQUN4RCw2REFBd0Q7QUFDeEQsdUVBQWtFO0FBc0JsRSxNQUFhLGVBQWU7SUFRMUIsWUFBWSxFQUNWLGlCQUFpQixFQUNqQixhQUFhLEVBQ2IsU0FBUyxFQUNULFVBQVUsS0FDUyxFQUFFO1FBUnZCLHFKQUFxSjtRQUNySSxhQUFRLEdBQUcsRUFBRSxlQUFlLEVBQUUsVUFBVSxFQUFFLENBQUM7UUFRek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25hbCkge1xuICAgICAgICBhYm9ydFNpZ25hbC5vbmFib3J0ID0gKCkgPT4ge1xuICAgICAgICAgIC8vIGVuc3VyZSByZXF1ZXN0IGlzIGRlc3Ryb3llZFxuICAgICAgICAgIHJlcS5hYm9ydCgpO1xuICAgICAgICAgIGNvbnN0IGFib3J0RXJyb3IgPSBuZXcgRXJyb3IoXCJSZXF1ZXN0IGFib3J0ZWRcIik7XG4gICAgICAgICAgYWJvcnRFcnJvci5uYW1lID0gXCJBYm9ydEVycm9yXCI7XG4gICAgICAgICAgcmVqZWN0KGFib3J0RXJyb3IpO1xuICAgICAgICB9O1xuICAgICAgfVxuXG4gICAgICB3cml0ZVJlcXVlc3RCb2R5KHJlcSwgcmVxdWVzdCk7XG4gICAgfSk7XG4gIH1cbn1cbiJdfQ==
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function setConnectionTimeout(request, reject, timeoutInMs) {
if (timeoutInMs === void 0) { timeoutInMs = 0; }
function setConnectionTimeout(request, reject, timeoutInMs = 0) {
if (!timeoutInMs) {

@@ -9,9 +8,8 @@ return;

request.on("socket", function (socket) {
var _this = this;
if (socket.connecting) {
// Throw a connecting timeout error unless a connection is made within x time
var timeoutId_1 = setTimeout(function () {
let timeoutId = setTimeout(() => {
// abort the request to destroy it
_this.abort();
var timeoutError = new Error("Socket timed out without establishing a connection within " + timeoutInMs + " ms");
this.abort();
const timeoutError = new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`);
timeoutError.name = "TimeoutError";

@@ -21,4 +19,4 @@ reject(timeoutError);

// if the connection was established, cancel the timeout
socket.on("connect", function () {
clearTimeout(timeoutId_1);
socket.on("connect", () => {
clearTimeout(timeoutId);
});

@@ -29,2 +27,2 @@ }

exports.setConnectionTimeout = setConnectionTimeout;
//# sourceMappingURL=set-connection-timeout.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0LWNvbm5lY3Rpb24tdGltZW91dC5qcyIsInNvdX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bWVvdXQodGltZW91dElkKTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfSk7XG59XG4iXX0=
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function setSocketTimeout(request, reject, timeoutInMs) {
if (timeoutInMs === void 0) { timeoutInMs = 0; }
function setSocketTimeout(request, reject, timeoutInMs = 0) {
request.setTimeout(timeoutInMs, function () {
// abort the request to destroy it
this.abort();
var timeoutError = new Error("Connection timed out after " + timeoutInMs + " ms");
const timeoutError = new Error(`Connection timed out after ${timeoutInMs} ms`);
timeoutError.name = "TimeoutError";

@@ -14,2 +13,2 @@ reject(timeoutError);

exports.setSocketTimeout = setSocketTimeout;
//# sourceMappingURL=set-socket-timeout.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0LXNvY2tldC10aW1lb3V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3NldC1zb2NrZXQtdGltZW91dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLFNBQWdCLGdCQUFnQixDQUM5QixPQUFzQixFQUN0QixNQUE0QixFQUM1QixjQUFzQixDQUFDO0lBRXZCLE9BQU8sQ0FBQyxVQUFVLENBQUMsV0FBVyxFQUFFO1FBQzlCLGtDQUFrQztRQUNsQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDYixNQUFNLFlBQVksR0FBRyxJQUFJLEtBQUssQ0FDNUIsOEJBQThCLFdBQVcsS0FBSyxDQUMvQyxDQUFDO1FBQ0YsWUFBWSxDQUFDLElBQUksR0FBRyxjQUFjLENBQUM7UUFDbkMsTUFBTSxDQUFDLFlBQVksQ0FBQyxDQUFDO0lBQ3ZCLENBQUMsQ0FBQyxDQUFDO0FBQ0wsQ0FBQztBQWRELDRDQWNDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ2xpZW50UmVxdWVzdCB9IGZyb20gXCJodHRwXCI7XG5cbmV4cG9ydCBmdW5jdGlvbiBzZXRTb2NrZXRUaW1lb3V0KFxuICByZXF1ZXN0OiBDbGllbnRSZXF1ZXN0LFxuICByZWplY3Q6IChlcnI6IEVycm9yKSA9PiB2b2lkLFxuICB0aW1lb3V0SW5NczogbnVtYmVyID0gMFxuKSB7XG4gIHJlcXVlc3Quc2V0VGltZW91dCh0aW1lb3V0SW5NcywgZnVuY3Rpb24odGhpczogQ2xpZW50UmVxdWVzdCkge1xuICAgIC8vIGFib3J0IHRoZSByZXF1ZXN0IHRvIGRlc3Ryb3kgaXRcbiAgICB0aGlzLmFib3J0KCk7XG4gICAgY29uc3QgdGltZW91dEVycm9yID0gbmV3IEVycm9yKFxuICAgICAgYENvbm5lY3Rpb24gdGltZWQgb3V0IGFmdGVyICR7dGltZW91dEluTXN9IG1zYFxuICAgICk7XG4gICAgdGltZW91dEVycm9yLm5hbWUgPSBcIlRpbWVvdXRFcnJvclwiO1xuICAgIHJlamVjdCh0aW1lb3V0RXJyb3IpO1xuICB9KTtcbn1cbiJdfQ==
/// <reference types="node" />
import { ClientRequest } from "http";
import { Readable } from "stream";
import { ClientHttp2Stream } from "http2";
import { HttpRequest } from "@aws-sdk/types";
export declare function writeRequestBody(httpRequest: ClientRequest, request: HttpRequest<Readable>): void;
export declare function writeRequestBody(httpRequest: ClientRequest | ClientHttp2Stream, request: HttpRequest): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var stream_1 = require("stream");
const stream_1 = require("stream");
function writeRequestBody(httpRequest, request) {
var expect = request.headers["Expect"] || request.headers["expect"];
const expect = request.headers["Expect"] || request.headers["expect"];
if (expect === "100-continue") {
httpRequest.on("continue", function () {
httpRequest.on("continue", () => {
writeBody(httpRequest, request.body);

@@ -28,2 +28,2 @@ });

}
//# sourceMappingURL=write-request-body.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid3JpdGUtcmVxdWVzdC1ib2R5LmpzIiwic291cmNlUm9vd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ib2R5KTtcbiAgfSBlbHNlIHtcbiAgICBodHRwUmVxdWVzdC5lbmQoKTtcbiAgfVxufVxuIl19

@@ -6,2 +6,49 @@ # Change Log

# [1.0.0-alpha.1](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/node-http-handler@0.1.0-preview.3...@aws-sdk/node-http-handler@1.0.0-alpha.1) (2020-01-08)
### Bug Fixes
* support custom agent in node http handler ([#489](https://github.com/aws/aws-sdk-js-v3/issues/489)) ([9c6cde8](https://github.com/aws/aws-sdk-js-v3/commit/9c6cde8))
* update updated types ([#474](https://github.com/aws/aws-sdk-js-v3/issues/474)) ([9efac3e](https://github.com/aws/aws-sdk-js-v3/commit/9efac3e))
### Features
* [WIP] Node.js HTTP/2 Handler in smithy-codegen ([#414](https://github.com/aws/aws-sdk-js-v3/issues/414)) ([1493cc3](https://github.com/aws/aws-sdk-js-v3/commit/1493cc3))
* add a middleware inserting right host header ([#567](https://github.com/aws/aws-sdk-js-v3/issues/567)) ([82649ae](https://github.com/aws/aws-sdk-js-v3/commit/82649ae))
* apply protocol and middleware update ([0de0a22](https://github.com/aws/aws-sdk-js-v3/commit/0de0a22))
# 0.6.0 (2019-10-30)
# 0.3.0 (2019-09-09)
### Features
* commit all clients ([#324](https://github.com/aws/aws-sdk-js-v3/issues/324)) ([cb268ed](https://github.com/aws/aws-sdk-js-v3/commit/cb268ed))
* node-http-handler set default keep-alive to true ([#307](https://github.com/aws/aws-sdk-js-v3/issues/307)) ([d709e50](https://github.com/aws/aws-sdk-js-v3/commit/d709e50))
# 0.2.0 (2019-07-12)
### Features
* add npm badges for individual packages ([#251](https://github.com/aws/aws-sdk-js-v3/issues/251)) ([8adc10c](https://github.com/aws/aws-sdk-js-v3/commit/8adc10c))
* update jest v20 to v24 ([#243](https://github.com/aws/aws-sdk-js-v3/issues/243)) ([1e156ab](https://github.com/aws/aws-sdk-js-v3/commit/1e156ab))
# 0.1.0 (2019-04-19)
# [0.1.0-preview.8](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/node-http-handler@0.1.0-preview.3...@aws-sdk/node-http-handler@0.1.0-preview.8) (2019-10-30)

@@ -8,0 +55,0 @@

{
"name": "@aws-sdk/node-http-handler",
"version": "0.1.0-preview.8",
"version": "1.0.0-alpha.1",
"description": "Provides a way to make requests",

@@ -12,2 +12,3 @@ "scripts": {

"name": "AWS SDK for JavaScript Team",
"email": "",
"url": "https://aws.amazon.com/javascript/"

@@ -19,5 +20,6 @@ },

"dependencies": {
"@aws-sdk/abort-controller": "^0.1.0-preview.7",
"@aws-sdk/querystring-builder": "^0.1.0-preview.7",
"@aws-sdk/types": "^0.1.0-preview.7",
"@aws-sdk/abort-controller": "^1.0.0-alpha.1",
"@aws-sdk/protocol-http": "^1.0.0-alpha.1",
"@aws-sdk/querystring-builder": "^1.0.0-alpha.1",
"@aws-sdk/types": "^1.0.0-alpha.1",
"tslib": "^1.8.0"

@@ -24,0 +26,0 @@ },

{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"module": "commonjs",

@@ -5,0 +5,0 @@ "declaration": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc