use default http timeout from util
This commit is contained in:
parent
db9d6dd394
commit
f1008c9661
@ -296,6 +296,12 @@ export namespace Duration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fromMilliseconds(ms: number): Duration {
|
||||||
|
return {
|
||||||
|
d_ms: ms,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function clamp(args: {
|
export function clamp(args: {
|
||||||
lower: Duration;
|
lower: Duration;
|
||||||
upper: Duration;
|
upper: Duration;
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
RequestThrottler,
|
RequestThrottler,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
TalerError,
|
TalerError,
|
||||||
|
Duration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -31,6 +32,7 @@ import {
|
|||||||
Headers,
|
Headers,
|
||||||
getDefaultHeaders,
|
getDefaultHeaders,
|
||||||
encodeBody,
|
encodeBody,
|
||||||
|
DEFAULT_REQUEST_TIMEOUT_MS,
|
||||||
} from "@gnu-taler/taler-util/http";
|
} from "@gnu-taler/taler-util/http";
|
||||||
|
|
||||||
const logger = new Logger("browserHttpLib");
|
const logger = new Logger("browserHttpLib");
|
||||||
@ -50,7 +52,8 @@ export class BrowserHttpLib implements HttpRequestLibrary {
|
|||||||
const requestMethod = options?.method ?? "GET";
|
const requestMethod = options?.method ?? "GET";
|
||||||
const requestBody = options?.body;
|
const requestBody = options?.body;
|
||||||
const requestHeader = options?.headers;
|
const requestHeader = options?.headers;
|
||||||
const requestTimeout = options?.timeout ?? { d_ms: 2 * 1000 };
|
const requestTimeout =
|
||||||
|
options?.timeout ?? Duration.fromMilliseconds(DEFAULT_REQUEST_TIMEOUT_MS);
|
||||||
|
|
||||||
if (this.throttlingEnabled && this.throttle.applyThrottle(requestUrl)) {
|
if (this.throttlingEnabled && this.throttle.applyThrottle(requestUrl)) {
|
||||||
const parsedUrl = new URL(requestUrl);
|
const parsedUrl = new URL(requestUrl);
|
||||||
|
@ -21,9 +21,11 @@ import {
|
|||||||
RequestThrottler,
|
RequestThrottler,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
TalerError,
|
TalerError,
|
||||||
|
Duration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
DEFAULT_REQUEST_TIMEOUT_MS,
|
||||||
Headers,
|
Headers,
|
||||||
HttpRequestLibrary,
|
HttpRequestLibrary,
|
||||||
HttpRequestOptions,
|
HttpRequestOptions,
|
||||||
@ -47,7 +49,8 @@ export class ServiceWorkerHttpLib implements HttpRequestLibrary {
|
|||||||
const requestMethod = options?.method ?? "GET";
|
const requestMethod = options?.method ?? "GET";
|
||||||
const requestBody = options?.body;
|
const requestBody = options?.body;
|
||||||
const requestHeader = options?.headers;
|
const requestHeader = options?.headers;
|
||||||
const requestTimeout = options?.timeout ?? { d_ms: 2 * 1000 };
|
const requestTimeout =
|
||||||
|
options?.timeout ?? Duration.fromMilliseconds(DEFAULT_REQUEST_TIMEOUT_MS);
|
||||||
|
|
||||||
if (this.throttlingEnabled && this.throttle.applyThrottle(requestUrl)) {
|
if (this.throttlingEnabled && this.throttle.applyThrottle(requestUrl)) {
|
||||||
const parsedUrl = new URL(requestUrl);
|
const parsedUrl = new URL(requestUrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user