Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/core-rest-pipeline

Package Overview
Dependencies
Maintainers
3
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-rest-pipeline - npm Package Compare versions

Comparing version 1.0.2-alpha.20210319.1 to 1.0.2-alpha.20210326.1

3

CHANGELOG.md
# Release History
## 1.0.2 (Unreleased)
## 1.0.2 (2021-03-25)
- Fixed an issue where chunked HTTP responses would sometimes be decoded incorrectly when multibyte characters were used. [PR 14517](https://github.com/Azure/azure-sdk-for-js/pull/14517)

@@ -6,0 +7,0 @@ ## 1.0.1 (2021-03-18)

@@ -8,4 +8,2 @@ // Copyright (c) Microsoft Corporation.

import { Transform } from "stream";
import { HttpsProxyAgent } from "https-proxy-agent";
import { HttpProxyAgent } from "http-proxy-agent";
import { AbortController, AbortError } from "@azure/abort-controller";

@@ -171,2 +169,3 @@ import { createHttpHeaders } from "./httpHeaders";

makeRequest(request, callback) {
var _a;
const url = new URL(request.url);

@@ -177,3 +176,3 @@ const isInsecure = url.protocol !== "https:";

}
const agent = this.getOrCreateAgent(request, isInsecure);
const agent = (_a = request.agent) !== null && _a !== void 0 ? _a : this.getOrCreateAgent(request, isInsecure);
const options = {

@@ -194,58 +193,21 @@ agent,

}
getProxyAgentOptions(proxySettings, requestHeaders) {
let parsedProxyUrl;
try {
parsedProxyUrl = new URL(proxySettings.host);
}
catch (_error) {
throw new Error(`Expecting a valid host string in proxy settings, but found "${proxySettings.host}".`);
}
const proxyAgentOptions = {
hostname: parsedProxyUrl.hostname,
port: proxySettings.port,
protocol: parsedProxyUrl.protocol,
headers: requestHeaders.toJSON()
};
if (proxySettings.username && proxySettings.password) {
proxyAgentOptions.auth = `${proxySettings.username}:${proxySettings.password}`;
}
return proxyAgentOptions;
}
getOrCreateAgent(request, isInsecure) {
// At the moment, proxy settings and keepAlive are mutually
// exclusive because the proxy library currently lacks the
// ability to create a proxy with keepAlive turned on.
const proxySettings = request.proxySettings;
if (proxySettings) {
if (!request.disableKeepAlive) {
if (isInsecure) {
if (!this.httpProxyAgent) {
const proxyAgentOptions = this.getProxyAgentOptions(proxySettings, request.headers);
this.httpProxyAgent = new HttpProxyAgent(proxyAgentOptions);
if (!this.httpKeepAliveAgent) {
this.httpKeepAliveAgent = new http.Agent({
keepAlive: true
});
}
return this.httpProxyAgent;
return this.httpKeepAliveAgent;
}
else {
if (!this.httpsProxyAgent) {
const proxyAgentOptions = this.getProxyAgentOptions(proxySettings, request.headers);
this.httpsProxyAgent = new HttpsProxyAgent(proxyAgentOptions);
if (!this.httpsKeepAliveAgent) {
this.httpsKeepAliveAgent = new https.Agent({
keepAlive: true
});
}
return this.httpsProxyAgent;
return this.httpsKeepAliveAgent;
}
}
else if (!request.disableKeepAlive && !isInsecure) {
if (!this.httpsKeepAliveAgent) {
this.httpsKeepAliveAgent = new https.Agent({
keepAlive: true
});
}
return this.httpsKeepAliveAgent;
}
else if (!request.disableKeepAlive && isInsecure) {
if (!this.httpKeepAliveAgent) {
this.httpKeepAliveAgent = new http.Agent({
keepAlive: true
});
}
return this.httpKeepAliveAgent;
}
else if (isInsecure) {

@@ -292,11 +254,11 @@ return http.globalAgent;

stream.on("data", (chunk) => {
if (typeof chunk === "string") {
if (Buffer.isBuffer(chunk)) {
buffer.push(chunk);
}
else {
buffer.push(chunk.toString());
buffer.push(Buffer.from(chunk));
}
});
stream.on("end", () => {
resolve(buffer.join(""));
resolve(Buffer.concat(buffer).toString("utf8"));
});

@@ -303,0 +265,0 @@ stream.on("error", (e) => {

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __awaiter } from "tslib";
import { HttpsProxyAgent } from "https-proxy-agent";
import { HttpProxyAgent } from "http-proxy-agent";
import { URL } from "../util/url";

@@ -15,2 +17,4 @@ const HTTPS_PROXY = "HTTPS_PROXY";

const byPassedList = new Map();
let httpsProxyAgent;
let httpProxyAgent;
function getEnvironmentValue(name) {

@@ -99,2 +103,42 @@ if (process.env[name]) {

}
function getProxyAgentOptions(proxySettings, requestHeaders) {
let parsedProxyUrl;
try {
parsedProxyUrl = new URL(proxySettings.host);
}
catch (_error) {
throw new Error(`Expecting a valid host string in proxy settings, but found "${proxySettings.host}".`);
}
const proxyAgentOptions = {
hostname: parsedProxyUrl.hostname,
port: proxySettings.port,
protocol: parsedProxyUrl.protocol,
headers: requestHeaders.toJSON()
};
if (proxySettings.username && proxySettings.password) {
proxyAgentOptions.auth = `${proxySettings.username}:${proxySettings.password}`;
}
return proxyAgentOptions;
}
function setProxyAgentOnRequest(request) {
const url = new URL(request.url);
const isInsecure = url.protocol !== "https:";
const proxySettings = request.proxySettings;
if (proxySettings) {
if (isInsecure) {
if (!httpProxyAgent) {
const proxyAgentOptions = getProxyAgentOptions(proxySettings, request.headers);
httpProxyAgent = new HttpProxyAgent(proxyAgentOptions);
}
request.agent = httpProxyAgent;
}
else {
if (!httpsProxyAgent) {
const proxyAgentOptions = getProxyAgentOptions(proxySettings, request.headers);
httpsProxyAgent = new HttpsProxyAgent(proxyAgentOptions);
}
request.agent = httpsProxyAgent;
}
}
}
/**

@@ -114,2 +158,5 @@ * A policy that allows one to apply proxy settings to all requests.

}
if (request.proxySettings) {
setProxyAgentOnRequest(request);
}
return next(request);

@@ -116,0 +163,0 @@ });

{
"name": "@azure/core-rest-pipeline",
"version": "1.0.2-alpha.20210319.1",
"version": "1.0.2-alpha.20210326.1",
"description": "Isomorphic client library for making HTTP requests in node.js and browser.",

@@ -55,3 +55,3 @@ "sdk-type": "client",

"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js dist-test/index.node.js",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js \"dist-test/index.node.js\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",

@@ -145,3 +145,3 @@ "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"

"source-map-support": "^0.5.9",
"typescript": "4.1.2",
"typescript": "~4.2.0",
"util": "^0.12.1",

@@ -148,0 +148,0 @@ "typedoc": "0.15.2"

@@ -29,2 +29,29 @@ /// <reference types="node" />

/**
* An interface compatible with NodeJS's `http.Agent`.
* We want to avoid publicly re-exporting the actual interface,
* since it might vary across runtime versions.
*/
export declare interface Agent {
/**
* Destroy any sockets that are currently in use by the agent.
*/
destroy(): void;
/**
* For agents with keepAlive enabled, this sets the maximum number of sockets that will be left open in the free state.
*/
maxFreeSockets: number;
/**
* Determines how many concurrent sockets the agent can have open per origin.
*/
maxSockets: number;
/**
* An object which contains queues of requests that have not yet been assigned to sockets.
*/
requests: unknown;
/**
* An object which contains arrays of sockets currently in use by the agent.
*/
sockets: unknown;
}
/**
* A policy that can request a token from a TokenCredential implementation and

@@ -387,2 +414,9 @@ * then apply it to the Authorization header of a request as a Bearer token.

allowInsecureConnection?: boolean;
/**
* NODEJS ONLY
*
* A Node-only option to provide a custom `http.Agent`/`https.Agent`.
* Does nothing when running in the browser.
*/
agent?: Agent;
}

@@ -389,0 +423,0 @@ /**

@@ -31,2 +31,30 @@ /// <reference types="node" />

/**
* An interface compatible with NodeJS's `http.Agent`.
* We want to avoid publicly re-exporting the actual interface,
* since it might vary across runtime versions.
*/
export declare interface Agent {
/**
* Destroy any sockets that are currently in use by the agent.
*/
destroy(): void;
/**
* For agents with keepAlive enabled, this sets the maximum number of sockets that will be left open in the free state.
*/
maxFreeSockets: number;
/**
* Determines how many concurrent sockets the agent can have open per origin.
*/
maxSockets: number;
/**
* An object which contains queues of requests that have not yet been assigned to sockets.
*/
requests: unknown;
/**
* An object which contains arrays of sockets currently in use by the agent.
*/
sockets: unknown;
}
/**
* A policy that can request a token from a TokenCredential implementation and

@@ -420,2 +448,9 @@ * then apply it to the Authorization header of a request as a Bearer token.

allowInsecureConnection?: boolean;
/**
* NODEJS ONLY
*
* A Node-only option to provide a custom `http.Agent`/`https.Agent`.
* Does nothing when running in the browser.
*/
agent?: Agent;
}

@@ -422,0 +457,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc