host is a forbidden header
This commit is contained in:
parent
16f42e5cd9
commit
cde8a2620a
10
src/net.ts
10
src/net.ts
|
@ -19,9 +19,10 @@ 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 = [
|
||||||
["Host", new URL(url).host],
|
["Date", now]
|
||||||
["Date", new Date().toUTCString()]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const headerNames = ["(request-target)", "host", "date"];
|
const headerNames = ["(request-target)", "host", "date"];
|
||||||
|
@ -52,7 +53,10 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si
|
||||||
const signature = signer.sign({
|
const signature = signer.sign({
|
||||||
url,
|
url,
|
||||||
method: init.method as string,
|
method: init.method as string,
|
||||||
headers: signedHeaders
|
headers: [
|
||||||
|
["Host", new URL(url).host],
|
||||||
|
...signedHeaders
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const newHeaders: HeadersInit =
|
const newHeaders: HeadersInit =
|
||||||
|
|
Loading…
Reference in New Issue