function createRequestExecutor(options, httpModule, agent) {
    var _a = new Url$2.URL(options.url), hostname = _a.hostname, pathname = _a.pathname, port = _a.port, protocol = _a.protocol, search = _a.search;
    return function makeRequest(request) {
        return new Promise(function (resolve, reject) {
            var req = httpModule.request({
                method: 'POST',
                agent: agent,
                headers: options.headers,
                hostname: hostname,
                path: "" + pathname + search,
                port: port,
                protocol: protocol,
                ca: options.caCerts,
            }, function (res) {
                var _a, _b, _c;
                res.on('data', function () {
                    // Drain socket
                });
                res.on('end', function () {
                    // Drain socket
                });
                var statusCode = (_a = res.statusCode, (_a !== null && _a !== void 0 ? _a : 500));
                var status = eventStatusFromHttpCode(statusCode);
                res.setEncoding('utf8');
                // "Key-value pairs of header names and values. Header names are lower-cased."
                // https://nodejs.org/api/http.html#http_message_headers
                var retryAfterHeader = (_b = res.headers['retry-after'], (_b !== null && _b !== void 0 ? _b : null));
                var rateLimitsHeader = (_c = res.headers['x-sentry-rate-limits'], (_c !== null && _c !== void 0 ? _c : null));
                resolve({
                    headers: {
                        'retry-after': retryAfterHeader,
                        'x-sentry-rate-limits': Array.isArray(rateLimitsHeader) ? rateLimitsHeader[0] : rateLimitsHeader,
                    },
                    reason: status,
                    statusCode: statusCode,
                });
            });
            req.on('error', reject);
            req.end(request.body);
        });
    };
}
Creates a RequestExecutor to be used with `createTransport`.