mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
bugfix #146: query params were being dropped on http webhook requests
This commit is contained in:
@@ -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)}),
|
||||
|
||||
Reference in New Issue
Block a user