bugfix #146: query params were being dropped on http webhook requests

This commit is contained in:
Dave Horton
2022-08-10 19:31:59 +02:00
parent 2a4f8e3ff9
commit a021ca19a5

View File

@@ -31,8 +31,10 @@ class HttpRequestor extends BaseRequestor {
this._baseUrl = `${u.protocol}://${u.resource}`;
this._resource = u.resource;
this._protocol = u.protocol;
this._search = u.search;
this._usePools = process.env.HTTP_POOL && parseInt(process.env.HTTP_POOL);
logger.debug({u, baseUrl: this.baseUrl}, 'HttpRequestor:constructor');
if (this._usePools) {
if (pools.has(this._baseUrl)) {
this.client = pools.get(this._baseUrl);
@@ -89,20 +91,25 @@ class HttpRequestor extends BaseRequestor {
let newClient;
try {
let client, path;
let client, path, query;
if (this._isRelativeUrl(url)) {
client = this.client;
path = url;
this.logger.debug({path}, 'HttpRequestor:request - relative url');
}
else {
const u = parseUrl(url);
if (u.resource === this._resource && u.protocol === this._protocol) {
client = this.client;
path = u.pathname;
query = u.query;
this.logger.debug({u, path}, 'HttpRequestor:request - abs url but reuse client');
}
else {
client = newClient = new Client(`${u.protocol}://${u.resource}`);
path = u.pathname;
query = u.query;
this.logger.debug({u, path}, 'HttpRequestor:request - abs url new client');
}
}
const sigHeader = this._generateSigHeader(payload, this.secret);
@@ -116,6 +123,7 @@ class HttpRequestor extends BaseRequestor {
this.logger.debug({url, absUrl, hdrs}, 'send webhook');
const {statusCode, headers, body} = await client.request({
path,
query,
method,
headers: hdrs,
...('POST' === method && {body: JSON.stringify(payload)}),