@actions/http-client
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -32,2 +32,7 @@ /// <reference types="node" /> | ||
} | ||
/** | ||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables. | ||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com | ||
*/ | ||
export declare function getProxyUrl(serverUrl: string): string; | ||
export declare class HttpClientResponse implements ifm.IHttpClientResponse { | ||
@@ -34,0 +39,0 @@ constructor(message: http.IncomingMessage); |
@@ -37,2 +37,11 @@ "use strict"; | ||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); | ||
/** | ||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables. | ||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com | ||
*/ | ||
function getProxyUrl(serverUrl) { | ||
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl)); | ||
return proxyUrl ? proxyUrl.href : ''; | ||
} | ||
exports.getProxyUrl = getProxyUrl; | ||
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect]; | ||
@@ -39,0 +48,0 @@ const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout]; |
{ | ||
"name": "@actions/http-client", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Actions Http Client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
/// <reference types="node" /> | ||
import * as url from 'url'; | ||
export declare function getProxyUrl(reqUrl: url.Url): url.Url; | ||
export declare function getProxyUrl(reqUrl: url.Url): url.Url | undefined; | ||
export declare function checkBypass(reqUrl: url.Url): boolean; |
50
proxy.js
@@ -6,19 +6,4 @@ "use strict"; | ||
let usingSsl = reqUrl.protocol === 'https:'; | ||
let noProxy = process.env["no_proxy"] || | ||
process.env["NO_PROXY"]; | ||
let bypass; | ||
if (noProxy && typeof noProxy === 'string') { | ||
let bypassList = noProxy.split(','); | ||
for (let i = 0; i < bypassList.length; i++) { | ||
let item = bypassList[i]; | ||
if (item && | ||
typeof item === "string" && | ||
reqUrl.host.toLocaleLowerCase() == item.trim().toLocaleLowerCase()) { | ||
bypass = true; | ||
break; | ||
} | ||
} | ||
} | ||
let proxyUrl; | ||
if (bypass) { | ||
if (checkBypass(reqUrl)) { | ||
return proxyUrl; | ||
@@ -41,1 +26,34 @@ } | ||
exports.getProxyUrl = getProxyUrl; | ||
function checkBypass(reqUrl) { | ||
if (!reqUrl.hostname) { | ||
return false; | ||
} | ||
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || ''; | ||
if (!noProxy) { | ||
return false; | ||
} | ||
// Determine the request port | ||
let reqPort; | ||
if (reqUrl.port) { | ||
reqPort = Number(reqUrl.port); | ||
} | ||
else if (reqUrl.protocol === 'http:') { | ||
reqPort = 80; | ||
} | ||
else if (reqUrl.protocol === 'https:') { | ||
reqPort = 443; | ||
} | ||
// Format the request hostname and hostname with port | ||
let upperReqHosts = [reqUrl.hostname.toUpperCase()]; | ||
if (typeof reqPort === 'number') { | ||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); | ||
} | ||
// Compare request host against noproxy | ||
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) { | ||
if (upperReqHosts.some(x => x === upperNoProxyItem)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
exports.checkBypass = checkBypass; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65361
672