summaryrefslogtreecommitdiff
path: root/together/node_modules/superagent/lib/node/http2wrapper.js
diff options
context:
space:
mode:
Diffstat (limited to 'together/node_modules/superagent/lib/node/http2wrapper.js')
-rw-r--r--together/node_modules/superagent/lib/node/http2wrapper.js210
1 files changed, 210 insertions, 0 deletions
diff --git a/together/node_modules/superagent/lib/node/http2wrapper.js b/together/node_modules/superagent/lib/node/http2wrapper.js
new file mode 100644
index 0000000..52d0b11
--- /dev/null
+++ b/together/node_modules/superagent/lib/node/http2wrapper.js
@@ -0,0 +1,210 @@
+"use strict";
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+const Stream = require('stream');
+
+const util = require('util');
+
+const net = require('net');
+
+const tls = require('tls'); // eslint-disable-next-line node/no-deprecated-api
+
+
+const _require = require('url'),
+ parse = _require.parse;
+
+const process = require('process');
+
+const semverGte = require('semver/functions/gte');
+
+let http2;
+if (semverGte(process.version, 'v10.10.0')) http2 = require('http2');else throw new Error('superagent: this version of Node.js does not support http2');
+const _http2$constants = http2.constants,
+ HTTP2_HEADER_PATH = _http2$constants.HTTP2_HEADER_PATH,
+ HTTP2_HEADER_STATUS = _http2$constants.HTTP2_HEADER_STATUS,
+ HTTP2_HEADER_METHOD = _http2$constants.HTTP2_HEADER_METHOD,
+ HTTP2_HEADER_AUTHORITY = _http2$constants.HTTP2_HEADER_AUTHORITY,
+ HTTP2_HEADER_HOST = _http2$constants.HTTP2_HEADER_HOST,
+ HTTP2_HEADER_SET_COOKIE = _http2$constants.HTTP2_HEADER_SET_COOKIE,
+ NGHTTP2_CANCEL = _http2$constants.NGHTTP2_CANCEL;
+
+function setProtocol(protocol) {
+ return {
+ request(options) {
+ return new Request(protocol, options);
+ }
+
+ };
+}
+
+function Request(protocol, options) {
+ Stream.call(this);
+ const defaultPort = protocol === 'https:' ? 443 : 80;
+ const defaultHost = 'localhost';
+ const port = options.port || defaultPort;
+ const host = options.host || defaultHost;
+ delete options.port;
+ delete options.host;
+ this.method = options.method;
+ this.path = options.path;
+ this.protocol = protocol;
+ this.host = host;
+ delete options.method;
+ delete options.path;
+
+ const sessionOptions = _objectSpread({}, options);
+
+ if (options.socketPath) {
+ sessionOptions.socketPath = options.socketPath;
+ sessionOptions.createConnection = this.createUnixConnection.bind(this);
+ }
+
+ this._headers = {};
+ const session = http2.connect("".concat(protocol, "//").concat(host, ":").concat(port), sessionOptions);
+ this.setHeader('host', "".concat(host, ":").concat(port));
+ session.on('error', error => this.emit('error', error));
+ this.session = session;
+}
+/**
+ * Inherit from `Stream` (which inherits from `EventEmitter`).
+ */
+
+
+util.inherits(Request, Stream);
+
+Request.prototype.createUnixConnection = function (authority, options) {
+ switch (this.protocol) {
+ case 'http:':
+ return net.connect(options.socketPath);
+
+ case 'https:':
+ options.ALPNProtocols = ['h2'];
+ options.servername = this.host;
+ options.allowHalfOpen = true;
+ return tls.connect(options.socketPath, options);
+
+ default:
+ throw new Error('Unsupported protocol', this.protocol);
+ }
+}; // eslint-disable-next-line no-unused-vars
+
+
+Request.prototype.setNoDelay = function (bool) {// We can not use setNoDelay with HTTP/2.
+ // Node 10 limits http2session.socket methods to ones safe to use with HTTP/2.
+ // See also https://nodejs.org/api/http2.html#http2_http2session_socket
+};
+
+Request.prototype.getFrame = function () {
+ if (this.frame) {
+ return this.frame;
+ }
+
+ const method = {
+ [HTTP2_HEADER_PATH]: this.path,
+ [HTTP2_HEADER_METHOD]: this.method
+ };
+ let headers = this.mapToHttp2Header(this._headers);
+ headers = Object.assign(headers, method);
+ const frame = this.session.request(headers); // eslint-disable-next-line no-unused-vars
+
+ frame.once('response', (headers, flags) => {
+ headers = this.mapToHttpHeader(headers);
+ frame.headers = headers;
+ frame.statusCode = headers[HTTP2_HEADER_STATUS];
+ frame.status = frame.statusCode;
+ this.emit('response', frame);
+ });
+ this._headerSent = true;
+ frame.once('drain', () => this.emit('drain'));
+ frame.on('error', error => this.emit('error', error));
+ frame.on('close', () => this.session.close());
+ this.frame = frame;
+ return frame;
+};
+
+Request.prototype.mapToHttpHeader = function (headers) {
+ const keys = Object.keys(headers);
+ const http2Headers = {};
+
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
+ let key = _keys[_i];
+ let value = headers[key];
+ key = key.toLowerCase();
+
+ switch (key) {
+ case HTTP2_HEADER_SET_COOKIE:
+ value = Array.isArray(value) ? value : [value];
+ break;
+
+ default:
+ break;
+ }
+
+ http2Headers[key] = value;
+ }
+
+ return http2Headers;
+};
+
+Request.prototype.mapToHttp2Header = function (headers) {
+ const keys = Object.keys(headers);
+ const http2Headers = {};
+
+ for (var _i2 = 0, _keys2 = keys; _i2 < _keys2.length; _i2++) {
+ let key = _keys2[_i2];
+ let value = headers[key];
+ key = key.toLowerCase();
+
+ switch (key) {
+ case HTTP2_HEADER_HOST:
+ key = HTTP2_HEADER_AUTHORITY;
+ value = /^http:\/\/|^https:\/\//.test(value) ? parse(value).host : value;
+ break;
+
+ default:
+ break;
+ }
+
+ http2Headers[key] = value;
+ }
+
+ return http2Headers;
+};
+
+Request.prototype.setHeader = function (name, value) {
+ this._headers[name.toLowerCase()] = value;
+};
+
+Request.prototype.getHeader = function (name) {
+ return this._headers[name.toLowerCase()];
+};
+
+Request.prototype.write = function (data, encoding) {
+ const frame = this.getFrame();
+ return frame.write(data, encoding);
+};
+
+Request.prototype.pipe = function (stream, options) {
+ const frame = this.getFrame();
+ return frame.pipe(stream, options);
+};
+
+Request.prototype.end = function (data) {
+ const frame = this.getFrame();
+ frame.end(data);
+}; // eslint-disable-next-line no-unused-vars
+
+
+Request.prototype.abort = function (data) {
+ const frame = this.getFrame();
+ frame.close(NGHTTP2_CANCEL);
+ this.session.destroy();
+};
+
+exports.setProtocol = setProtocol;
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJTdHJlYW0iLCJyZXF1aXJlIiwidXRpbCIsIm5ldCIsInRscyIsInBhcnNlIiwicHJvY2VzcyIsInNlbXZlckd0ZSIsImh0dHAyIiwidmVyc2lvbiIsIkVycm9yIiwiY29uc3RhbnRzIiwiSFRUUDJfSEVBREVSX1BBVEgiLCJIVFRQMl9IRUFERVJfU1RBVFVTIiwiSFRUUDJfSEVBREVSX01FVEhPRCIsIkhUVFAyX0hFQURFUl9BVVRIT1JJVFkiLCJIVFRQMl9IRUFERVJfSE9TVCIsIkhUVFAyX0hFQURFUl9TRVRfQ09PS0lFIiwiTkdIVFRQMl9DQU5DRUwiLCJzZXRQcm90b2NvbCIsInByb3RvY29sIiwicmVxdWVzdCIsIm9wdGlvbnMiLCJSZXF1ZXN0IiwiY2FsbCIsImRlZmF1bHRQb3J0IiwiZGVmYXVsdEhvc3QiLCJwb3J0IiwiaG9zdCIsIm1ldGhvZCIsInBhdGgiLCJzZXNzaW9uT3B0aW9ucyIsInNvY2tldFBhdGgiLCJjcmVhdGVDb25uZWN0aW9uIiwiY3JlYXRlVW5peENvbm5lY3Rpb24iLCJiaW5kIiwiX2hlYWRlcnMiLCJzZXNzaW9uIiwiY29ubmVjdCIsInNldEhlYWRlciIsIm9uIiwiZXJyb3IiLCJlbWl0IiwiaW5oZXJpdHMiLCJwcm90b3R5cGUiLCJhdXRob3J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