ms-rest-js/lib/proxyAgent.ts

82 строки
2.5 KiB
TypeScript
Исходник Постоянная ссылка Обычный вид История

Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import * as http from "http";
import * as https from "https";
import * as tunnel from "tunnel";
import { ProxySettings } from "./serviceClient";
import { URLBuilder } from "./url";
import { HttpHeadersLike } from "./httpHeaders";
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
export type ProxyAgent = { isHttps: boolean; agent: http.Agent | https.Agent };
export function createProxyAgent(
requestUrl: string,
proxySettings: ProxySettings,
headers?: HttpHeadersLike
): ProxyAgent {
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
const tunnelOptions: tunnel.HttpsOverHttpsOptions = {
proxy: {
host: URLBuilder.parse(proxySettings.host).getHost() as string,
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
port: proxySettings.port,
headers: (headers && headers.rawHeaders()) || {},
},
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
};
if (proxySettings.username && proxySettings.password) {
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}:${proxySettings.password}`;
} else if (proxySettings.username) {
tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}`;
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
}
const requestScheme = URLBuilder.parse(requestUrl).getScheme() || "";
const isRequestHttps = requestScheme.toLowerCase() === "https";
const proxyScheme = URLBuilder.parse(proxySettings.host).getScheme() || "";
const isProxyHttps = proxyScheme.toLowerCase() === "https";
const proxyAgent = {
isHttps: isRequestHttps,
agent: createTunnel(isRequestHttps, isProxyHttps, tunnelOptions),
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
};
return proxyAgent;
}
// Duplicate tunnel.HttpsOverHttpsOptions to avoid exporting createTunnel() with dependency on @types/tunnel
// createIunnel() is only imported by tests.
export interface HttpsProxyOptions {
host: string;
port: number;
localAddress?: string;
proxyAuth?: string;
headers?: { [key: string]: any };
ca?: Buffer[];
servername?: string;
key?: Buffer;
cert?: Buffer;
}
interface HttpsOverHttpsOptions {
maxSockets?: number;
ca?: Buffer[];
key?: Buffer;
cert?: Buffer;
proxy?: HttpsProxyOptions;
}
export function createTunnel(
isRequestHttps: boolean,
isProxyHttps: boolean,
tunnelOptions: HttpsOverHttpsOptions
): http.Agent | https.Agent {
Add support for Fetch in Node.js environment (#351) * Update version * Add Fetch HTTP client (#342) * Add Fetch HTTP client * Reset version * Update version * Fix isNode method to return true in Electron apps * Update Constants * Fix incorrect undefined check in Axios client * Add TSLint check. Fix TSLint errors (#344) * Add TSLint check. Fix TSLint errors * Add type to delay callback * Update TypeScript * Remove unnecessary types/xhr-mock package * Fix missing delay import * Reformat Fetch client * Fix wrong union type * Fix tests * Normalize the safe-check * Add script to run tests on dependent projects (#345) * Add script to run tests on dependent projects * Bump the version * Fix logging statements * Update constants * Update Azure Pipelines configuration * Fix Azure Pipeline job name * Add gulp build command * Add npm run local * Flip order * Add build step * Add more logging * Fix undefined result print * Remove inheriting stdio * Change to spawnSync * Add more logging * Remove build step * Change exec to run from JS dev tools * Add logger-js package * Add build step back * Add process.exit * Add logging * Change error logging * Add command printing * Extract options object * Add fullOptions parameter * Change NPM command name * Remove logging * Remove npm run test * Await additional commands * Add test command to package.json * Add timeout * Add test as separate task * Change foreach to for * Remove test from package.json command * Uncomment npm install commands * Add latest ms-rest-js to npm install * Add autorest.typescript DevOps task * Add npm link * Change link to install * Remove prepack script * Change package name to ../.. * Remove rm -rf * Add build step * Add git checkout * Add dependent project directory * Remove git branch checkout * Bump the version to 1.8.6 * Add git checkout * Change branch name * Add execution directory * Remove git checkout * Add tsc --version command * Remove local ms-rest-js install * Move .tmp folder * Change .tmp path creation * Fix path in Azure DevOps config * Renable logging * Add run to build command * Move scripts back to TypeScript * Improve logging * Fixed #347 and #348 * nit fix * bump version in the constant file. * Address reiew feedback * upgrade ci to run node 8, 10, 12 versions. Remove 6.x. * Reformat mockHttp * Add Fetch to browser * Add Firefox Karma configuration * Switch from isomorphic-fetch to cross-fetch * Add cross-fetch to rollup configuration * Remove buffer and streams from webpack test configuration * Add Firefox karma launcher * Add FetchMock for browser scenarios * Extract platform specific code to child classes * Bump the version * Add proxy support to fetch client (#350) * Remove cross-fetch * Add proxy support * Fix stream upload tests * Extract ProxyAgent * Bring XHR as default client for browsers * Address feedback * Bring back browser mock * Add type * Fix pass through mock * Change import type * Fix fetch import * Change fetch reference * Remove cross fetch from rollup config * Remote unit.ts * Add fallback fetch reference * Fix constants * Fix fetch bugs * Upgrade TypeScript * Remove unnecessary code from mock class * Remove type * Change vresion to preview * Remove Method import * Fix user agent tests * Remove Method casting * Remove Method type * Disable ms-rest-azure-js installation in CI * Fix pack order * Add keep-alive support (#362) * Remove remaining axios references * Update documentation * Add missing external packages in rollup config * Add Keep-Alive changelog * Bump the version
2019-06-24 19:01:20 +03:00
if (isRequestHttps && isProxyHttps) {
return tunnel.httpsOverHttps(tunnelOptions);
} else if (isRequestHttps && !isProxyHttps) {
return tunnel.httpsOverHttp(tunnelOptions);
} else if (!isRequestHttps && isProxyHttps) {
return tunnel.httpOverHttps(tunnelOptions);
} else {
return tunnel.httpOverHttp(tunnelOptions);
}
}