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