- I can't remove any default header.
- Setting
"connection": "keep-alive" throws an error.
- I can't overwrite default
"sec-fetch-mode" header correctly.
1. I can't remove the default headers
I can't remove the default headers: host, connection, accept, accept-encoding, accept-language, sec-fetch-mode, user-agent.
For example, curl allows to remove any header (even host header):
curl http://127.0.0.1:3000 -H 'User-Agent:' -H 'Accept:' -H 'Host:'
And yes, it works.
Using of "" will send "" as the header's value, using of null will send "null" as the header's value.
2. "connection": "keep-alive"
Also, if I manually set connection: "keep-alive" I get the error (code: 'UND_ERR_INVALID_ARG').
const resp = await fetch(url, {
headers: {
"connection": "keep-alive"
}
});
It's important for code compatibility reason — since node-fetch uses connection: close by default.
3. "sec-fetch-mode"
It uses "sec-fetch-mode": "cors" by default.
As I said above, I can't remove this header (as well as any other default header).
More over, I can't change it correctly.
For example, using of:
await fetch(url, {
headers: {
"sec-fetch-mode": "navigate"
}
});
Will produce a request with sec-fetch-mode: navigate, cors, while it should be sec-fetch-mode: navigate.
"undici": "4.16.0"
"connection": "keep-alive"throws an error."sec-fetch-mode"header correctly.1. I can't remove the default headers
I can't remove the default headers:
host,connection,accept,accept-encoding,accept-language,sec-fetch-mode,user-agent.For example,
curlallows to remove any header (evenhostheader):curl http://127.0.0.1:3000 -H 'User-Agent:' -H 'Accept:' -H 'Host:'And yes, it works.
Using of
""will send""as the header's value, using ofnullwill send"null"as the header's value.2.
"connection": "keep-alive"Also, if I manually set
connection: "keep-alive"I get the error (code: 'UND_ERR_INVALID_ARG').It's important for code compatibility reason — since
node-fetchusesconnection: closeby default.3.
"sec-fetch-mode"It uses
"sec-fetch-mode": "cors"by default.As I said above, I can't remove this header (as well as any other default header).
More over, I can't change it correctly.
For example, using of:
Will produce a request with
sec-fetch-mode: navigate, cors, while it should besec-fetch-mode: navigate."undici": "4.16.0"