aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-common.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-23 00:52:10 +0100
committerFlorian Dold <florian@dold.me>2023-02-23 00:52:17 +0100
commit7985b0a33ffc3e258da5d73f4056384c38e626fe (patch)
tree68908cb8ac2d49551f22bb4745bdf541156b8be5 /packages/taler-util/src/http-common.ts
parent7879efcff70ea73935e139f4522aedadfe755c04 (diff)
taler-harness: deployment tooling for tipping
Diffstat (limited to 'packages/taler-util/src/http-common.ts')
-rw-r--r--packages/taler-util/src/http-common.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/packages/taler-util/src/http-common.ts b/packages/taler-util/src/http-common.ts
index 54f26e615..e5dd92567 100644
--- a/packages/taler-util/src/http-common.ts
+++ b/packages/taler-util/src/http-common.ts
@@ -59,7 +59,7 @@ export interface HttpRequestOptions {
*/
cancellationToken?: CancellationToken;
- body?: string | ArrayBuffer | Record<string, unknown>;
+ body?: string | ArrayBuffer | object;
}
/**
@@ -344,9 +344,8 @@ export function getExpiry(
return t;
}
-
export interface HttpLibArgs {
- enableThrottling?: boolean,
+ enableThrottling?: boolean;
}
export function encodeBody(body: any): ArrayBuffer {
@@ -364,3 +363,16 @@ export function encodeBody(body: any): ArrayBuffer {
}
throw new TypeError("unsupported request body type");
}
+
+export function getDefaultHeaders(method: string): Record<string, string> {
+ const headers: Record<string, string> = {};
+
+ if (method === "POST" || method === "PUT" || method === "PATCH") {
+ // Default to JSON if we have a body
+ headers["Content-Type"] = "application/json";
+ }
+
+ headers["Accept"] = "application/json";
+
+ return headers;
+}