include content type in signed if post
This commit is contained in:
parent
cde8a2620a
commit
37daf35110
11
src/net.ts
11
src/net.ts
|
@ -19,16 +19,16 @@ export interface SignedInit {
|
||||||
|
|
||||||
// TODO: Handle redirects.
|
// TODO: Handle redirects.
|
||||||
export const signedFetch = async (url: string, init: RequestInit, signedInit: SignedInit): Promise<globalThis.Response> => {
|
export const signedFetch = async (url: string, init: RequestInit, signedInit: SignedInit): Promise<globalThis.Response> => {
|
||||||
const now = new Date().toUTCString();
|
|
||||||
|
|
||||||
const signedHeaders: HeadersInit = [
|
const signedHeaders: HeadersInit = [
|
||||||
["Date", now]
|
["Date", new Date().toUTCString()]
|
||||||
];
|
];
|
||||||
|
|
||||||
const headerNames = ["(request-target)", "host", "date"];
|
const headerNames = ["(request-target)", "host", "date"];
|
||||||
|
|
||||||
if (init.method === "POST") {
|
if (init.method === "POST") {
|
||||||
headerNames.push("digest");
|
headerNames.push("content-type", "digest");
|
||||||
|
|
||||||
|
signedHeaders.push(["Content-Type", `application/ld+json; profile="${CONTEXT}"`]);
|
||||||
|
|
||||||
if (init.body) {
|
if (init.body) {
|
||||||
if (signedInit.digest) {
|
if (signedInit.digest) {
|
||||||
|
@ -62,8 +62,7 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si
|
||||||
const newHeaders: HeadersInit =
|
const newHeaders: HeadersInit =
|
||||||
[
|
[
|
||||||
...signedHeaders,
|
...signedHeaders,
|
||||||
["Signature", signature],
|
["Signature", signature]
|
||||||
["Content-Type", `application/ld+json; profile="${CONTEXT}"`]
|
|
||||||
]
|
]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue