Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/connection/connections/HttpConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ export default class HttpConnection implements IConnectionProvider {
: '';
const proxyUrl = `${proxyOptions.protocol}://${proxyAuth}${proxyOptions.host}:${proxyOptions.port}`;

const proxyProtocol = `${proxyOptions.protocol}:`;

return new ProxyAgent({
...this.getAgentDefaultOptions(),
getProxyForUrl: () => proxyUrl,
httpsAgent: this.createHttpsAgent(),
httpAgent: this.createHttpAgent(),
protocol: proxyProtocol,
});
}

Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/proxy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ describe('Proxy', () => {
const proxy = new HttpProxyMock(`https://${config.host}`, 9090);
try {
const client = new DBSQLClient();

// Our proxy mock is HTTP -> HTTPS, but DBSQLClient is hard-coded to use HTTPS.
// Here we override default behavior to make DBSQLClient work with HTTP proxy
const originalGetConnectionOptions = client.getConnectionOptions;
client.getConnectionOptions = (...args) => {
const result = originalGetConnectionOptions.apply(client, args);
result.https = false;
result.port = 80;
return result;
};

const clientConfig = client.getConfig();
sinon.stub(client, 'getConfig').returns(clientConfig);

Expand Down