pull/15/head
Automated 2020-10-22 16:03:35 +00:00
parent 633f3dcdd7
commit 5360ef6587
1 changed files with 19 additions and 16 deletions

35
dist/index.js vendored
View File

@ -1143,7 +1143,6 @@ class ExecState extends events.EventEmitter {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const url = __webpack_require__(8835);
const http = __webpack_require__(8605); const http = __webpack_require__(8605);
const https = __webpack_require__(7211); const https = __webpack_require__(7211);
const pm = __webpack_require__(6443); const pm = __webpack_require__(6443);
@ -1192,7 +1191,7 @@ var MediaTypes;
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
*/ */
function getProxyUrl(serverUrl) { function getProxyUrl(serverUrl) {
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl)); let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
return proxyUrl ? proxyUrl.href : ''; return proxyUrl ? proxyUrl.href : '';
} }
exports.getProxyUrl = getProxyUrl; exports.getProxyUrl = getProxyUrl;
@ -1211,6 +1210,15 @@ const HttpResponseRetryCodes = [
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
const ExponentialBackoffCeiling = 10; const ExponentialBackoffCeiling = 10;
const ExponentialBackoffTimeSlice = 5; const ExponentialBackoffTimeSlice = 5;
class HttpClientError extends Error {
constructor(message, statusCode) {
super(message);
this.name = 'HttpClientError';
this.statusCode = statusCode;
Object.setPrototypeOf(this, HttpClientError.prototype);
}
}
exports.HttpClientError = HttpClientError;
class HttpClientResponse { class HttpClientResponse {
constructor(message) { constructor(message) {
this.message = message; this.message = message;
@ -1229,7 +1237,7 @@ class HttpClientResponse {
} }
exports.HttpClientResponse = HttpClientResponse; exports.HttpClientResponse = HttpClientResponse;
function isHttps(requestUrl) { function isHttps(requestUrl) {
let parsedUrl = url.parse(requestUrl); let parsedUrl = new URL(requestUrl);
return parsedUrl.protocol === 'https:'; return parsedUrl.protocol === 'https:';
} }
exports.isHttps = isHttps; exports.isHttps = isHttps;
@ -1334,7 +1342,7 @@ class HttpClient {
if (this._disposed) { if (this._disposed) {
throw new Error('Client has already been disposed.'); throw new Error('Client has already been disposed.');
} }
let parsedUrl = url.parse(requestUrl); let parsedUrl = new URL(requestUrl);
let info = this._prepareRequest(verb, parsedUrl, headers); let info = this._prepareRequest(verb, parsedUrl, headers);
// Only perform retries on reads since writes may not be idempotent. // Only perform retries on reads since writes may not be idempotent.
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
@ -1373,7 +1381,7 @@ class HttpClient {
// if there's no location to redirect to, we won't // if there's no location to redirect to, we won't
break; break;
} }
let parsedRedirectUrl = url.parse(redirectUrl); let parsedRedirectUrl = new URL(redirectUrl);
if (parsedUrl.protocol == 'https:' && if (parsedUrl.protocol == 'https:' &&
parsedUrl.protocol != parsedRedirectUrl.protocol && parsedUrl.protocol != parsedRedirectUrl.protocol &&
!this._allowRedirectDowngrade) { !this._allowRedirectDowngrade) {
@ -1489,7 +1497,7 @@ class HttpClient {
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
*/ */
getAgent(serverUrl) { getAgent(serverUrl) {
let parsedUrl = url.parse(serverUrl); let parsedUrl = new URL(serverUrl);
return this._getAgent(parsedUrl); return this._getAgent(parsedUrl);
} }
_prepareRequest(method, requestUrl, headers) { _prepareRequest(method, requestUrl, headers) {
@ -1562,7 +1570,7 @@ class HttpClient {
maxSockets: maxSockets, maxSockets: maxSockets,
keepAlive: this._keepAlive, keepAlive: this._keepAlive,
proxy: { proxy: {
proxyAuth: proxyUrl.auth, proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`,
host: proxyUrl.hostname, host: proxyUrl.hostname,
port: proxyUrl.port port: proxyUrl.port
} }
@ -1657,12 +1665,8 @@ class HttpClient {
else { else {
msg = 'Failed request: (' + statusCode + ')'; msg = 'Failed request: (' + statusCode + ')';
} }
let err = new Error(msg); let err = new HttpClientError(msg, statusCode);
// attach statusCode and body obj (if available) to the error object err.result = response.result;
err['statusCode'] = statusCode;
if (response.result) {
err['result'] = response.result;
}
reject(err); reject(err);
} }
else { else {
@ -1677,12 +1681,11 @@ exports.HttpClient = HttpClient;
/***/ }), /***/ }),
/***/ 6443: /***/ 6443:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { /***/ ((__unused_webpack_module, exports) => {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const url = __webpack_require__(8835);
function getProxyUrl(reqUrl) { function getProxyUrl(reqUrl) {
let usingSsl = reqUrl.protocol === 'https:'; let usingSsl = reqUrl.protocol === 'https:';
let proxyUrl; let proxyUrl;
@ -1697,7 +1700,7 @@ function getProxyUrl(reqUrl) {
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
} }
if (proxyVar) { if (proxyVar) {
proxyUrl = url.parse(proxyVar); proxyUrl = new URL(proxyVar);
} }
return proxyUrl; return proxyUrl;
} }