Skip to content

Commit 50ab723

Browse files
jeremymengxirzec
andauthored
[core-https] Fix proxy issue (Azure#13911)
* [core-https] Fix proxy issue There's some difference between the previous `tunnel.HttpsOverHttpsOptions` and current `HttpsProxyAgentOptions`, in particular the former's `host` property includes both the protocol and the host parts, while the later have separate `host` and `protocol` properties. * Address CR feedback * Better error message that include the invalid host string Co-authored-by: Jeff Fisher <xirzec@xirzec.com> * RangeError => Error Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
1 parent 5ab0b88 commit 50ab723

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

sdk/core/core-https/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.0.0-beta.2 (Unreleased)
44

55
- Changed from exposing `DefaultHttpsClient` as a class directly, to providing `createDefaultHttpsClient()` to instantiate the appropriate runtime class.
6+
- Fix an issue when passing in proxy hosts. [PR 13911](https://github.com/Azure/azure-sdk-for-js/pull/13911)
67

78
## 1.0.0-beta.1 (2021-02-04)
89

sdk/core/core-https/src/nodeHttpsClient.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,17 @@ class NodeHttpsClient implements HttpsClient {
198198
const proxySettings = request.proxySettings;
199199
if (proxySettings) {
200200
if (!this.proxyAgent) {
201+
let parsedUrl: URL;
202+
try {
203+
parsedUrl = new URL(proxySettings.host);
204+
} catch (_error) {
205+
throw new Error(`Expecting a valid host string in proxy settings, but found "${proxySettings.host}".`);
206+
}
207+
201208
const proxyAgentOptions: HttpsProxyAgentOptions = {
202-
host: proxySettings.host,
209+
hostname: parsedUrl.hostname,
203210
port: proxySettings.port,
211+
protocol: parsedUrl.protocol,
204212
headers: request.headers.toJSON()
205213
};
206214
if (proxySettings.username && proxySettings.password) {

0 commit comments

Comments
 (0)