Skip to content

Commit d8244c2

Browse files
Fix: proxy agent unintentionally overwrites protocol in URL (#241)
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
1 parent 4592c40 commit d8244c2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/connection/connections/HttpConnection.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,11 @@ export default class HttpConnection implements IConnectionProvider {
8282
: '';
8383
const proxyUrl = `${proxyOptions.protocol}://${proxyAuth}${proxyOptions.host}:${proxyOptions.port}`;
8484

85-
const proxyProtocol = `${proxyOptions.protocol}:`;
86-
8785
return new ProxyAgent({
8886
...this.getAgentDefaultOptions(),
8987
getProxyForUrl: () => proxyUrl,
9088
httpsAgent: this.createHttpsAgent(),
9189
httpAgent: this.createHttpAgent(),
92-
protocol: proxyProtocol,
9390
});
9491
}
9592

tests/e2e/proxy.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ describe('Proxy', () => {
5050
const proxy = new HttpProxyMock(`https://${config.host}`, 9090);
5151
try {
5252
const client = new DBSQLClient();
53+
54+
// Our proxy mock is HTTP -> HTTPS, but DBSQLClient is hard-coded to use HTTPS.
55+
// Here we override default behavior to make DBSQLClient work with HTTP proxy
56+
const originalGetConnectionOptions = client.getConnectionOptions;
57+
client.getConnectionOptions = (...args) => {
58+
const result = originalGetConnectionOptions.apply(client, args);
59+
result.https = false;
60+
result.port = 80;
61+
return result;
62+
};
63+
5364
const clientConfig = client.getConfig();
5465
sinon.stub(client, 'getConfig').returns(clientConfig);
5566

0 commit comments

Comments
 (0)