Skip to content

Commit

Permalink
Fix web FetchRequest does not respect disableConnectivityCheck clie…
Browse files Browse the repository at this point in the history
…nt option
  • Loading branch information
VeskeR committed Nov 22, 2024
1 parent 3f1ecab commit f4acc4a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/platform/web/lib/http/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,25 @@ const Http = class {
this.Request = async (method, uri, headers, params, body) => {
return fetchRequestImplementation(method, client ?? null, uri, headers, params, body);
};
this.checkConnectivity = async function () {
Logger.logAction(
this.logger,
Logger.LOG_MICRO,
'(Fetch)Http.checkConnectivity()',
'Sending; ' + connectivityCheckUrl,
);
const requestResult = await this.doUri(HttpMethods.Get, connectivityCheckUrl, null, null, null);
const result = !requestResult.error && (requestResult.body as string)?.replace(/\n/, '') == 'yes';
Logger.logAction(this.logger, Logger.LOG_MICRO, '(Fetch)Http.checkConnectivity()', 'Result: ' + result);
return result;
};

if (client?.options.disableConnectivityCheck) {
this.checkConnectivity = async function () {
return true;
};
} else {
this.checkConnectivity = async function () {
Logger.logAction(
this.logger,
Logger.LOG_MICRO,
'(Fetch)Http.checkConnectivity()',
'Sending; ' + connectivityCheckUrl,
);
const requestResult = await this.doUri(HttpMethods.Get, connectivityCheckUrl, null, null, null);
const result = !requestResult.error && (requestResult.body as string)?.replace(/\n/, '') == 'yes';
Logger.logAction(this.logger, Logger.LOG_MICRO, '(Fetch)Http.checkConnectivity()', 'Result: ' + result);
return result;
};
}
} else {
this.Request = async () => {
const error = hasImplementation
Expand Down

0 comments on commit f4acc4a

Please sign in to comment.