2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2022-10-10 12:06:50 -04:00
|
|
|
import { assert, assertEquals, assertThrows } from "./test_util.ts";
|
2019-10-28 12:23:39 -04:00
|
|
|
const {
|
2020-07-11 00:52:18 -04:00
|
|
|
inspectArgs,
|
2020-05-26 10:02:16 -04:00
|
|
|
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
2020-04-27 19:06:03 -04:00
|
|
|
} = Deno[Deno.internal];
|
2018-11-02 21:43:37 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headersHasCorrectNameProp() {
|
2020-05-31 16:07:24 -04:00
|
|
|
assertEquals(Headers.name, "Headers");
|
|
|
|
});
|
|
|
|
|
2018-11-02 21:43:37 -04:00
|
|
|
// Logic heavily copied from web-platform-tests, make
|
|
|
|
// sure pass mostly header basic test
|
|
|
|
// ref: https://github.com/web-platform-tests/wpt/blob/7c50c216081d6ea3c9afe553ee7b64534020a1b2/fetch/api/headers/headers-basic.html
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function newHeaderTest() {
|
2018-11-02 21:43:37 -04:00
|
|
|
new Headers();
|
|
|
|
new Headers(undefined);
|
|
|
|
new Headers({});
|
|
|
|
try {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
new Headers(null as any);
|
2018-11-02 21:43:37 -04:00
|
|
|
} catch (e) {
|
2021-04-18 19:00:13 -04:00
|
|
|
assert(e instanceof TypeError);
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-19 15:36:18 -05:00
|
|
|
const headerDict: Record<string, string> = {
|
2018-11-02 21:43:37 -04:00
|
|
|
name1: "value1",
|
|
|
|
name2: "value2",
|
|
|
|
name3: "value3",
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
name4: undefined as any,
|
2020-03-28 13:03:49 -04:00
|
|
|
"Content-Type": "value4",
|
2018-11-02 21:43:37 -04:00
|
|
|
};
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-02-19 15:36:18 -05:00
|
|
|
const headerSeq: any[] = [];
|
2018-11-02 21:43:37 -04:00
|
|
|
for (const name in headerDict) {
|
|
|
|
headerSeq.push([name, headerDict[name]]);
|
|
|
|
}
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function newHeaderWithSequence() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerSeq);
|
|
|
|
for (const name in headerDict) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get(name), String(headerDict[name]));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get("length"), null);
|
2018-11-02 21:43:37 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function newHeaderWithRecord() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
for (const name in headerDict) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get(name), String(headerDict[name]));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function newHeaderWithHeadersInstance() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
const headers2 = new Headers(headers);
|
|
|
|
for (const name in headerDict) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers2.get(name), String(headerDict[name]));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerAppendSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers();
|
|
|
|
for (const name in headerDict) {
|
|
|
|
headers.append(name, headerDict[name]);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get(name), String(headerDict[name]));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerSetSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers();
|
|
|
|
for (const name in headerDict) {
|
|
|
|
headers.set(name, headerDict[name]);
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get(name), String(headerDict[name]));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerHasSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
for (const name in headerDict) {
|
|
|
|
assert(headers.has(name), "headers has name " + name);
|
|
|
|
assert(
|
|
|
|
!headers.has("nameNotInHeaders"),
|
2020-07-14 15:24:17 -04:00
|
|
|
"headers do not have header: nameNotInHeaders",
|
2018-11-02 21:43:37 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerDeleteSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
for (const name in headerDict) {
|
|
|
|
assert(headers.has(name), "headers have a header: " + name);
|
|
|
|
headers.delete(name);
|
|
|
|
assert(!headers.has(name), "headers do not have anymore a header: " + name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerGetSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
for (const name in headerDict) {
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(headers.get(name), String(headerDict[name]));
|
|
|
|
assertEquals(headers.get("nameNotInHeaders"), null);
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerEntriesSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
const iterators = headers.entries();
|
|
|
|
for (const it of iterators) {
|
|
|
|
const key = it[0];
|
|
|
|
const value = it[1];
|
|
|
|
assert(headers.has(key));
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(value, headers.get(key));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerKeysSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
const iterators = headers.keys();
|
|
|
|
for (const it of iterators) {
|
|
|
|
assert(headers.has(it));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerValuesSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerDict);
|
|
|
|
const iterators = headers.values();
|
|
|
|
const entries = headers.entries();
|
|
|
|
const values = [];
|
|
|
|
for (const pair of entries) {
|
|
|
|
values.push(pair[1]);
|
|
|
|
}
|
|
|
|
for (const it of iterators) {
|
|
|
|
assert(values.includes(it));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-19 15:36:18 -05:00
|
|
|
const headerEntriesDict: Record<string, string> = {
|
2018-11-02 21:43:37 -04:00
|
|
|
name1: "value1",
|
|
|
|
Name2: "value2",
|
|
|
|
name: "value3",
|
|
|
|
"content-Type": "value4",
|
|
|
|
"Content-Typ": "value5",
|
2020-03-28 13:03:49 -04:00
|
|
|
"Content-Types": "value6",
|
2018-11-02 21:43:37 -04:00
|
|
|
};
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerForEachSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
const headers = new Headers(headerEntriesDict);
|
|
|
|
const keys = Object.keys(headerEntriesDict);
|
2021-08-05 07:08:58 -04:00
|
|
|
keys.forEach((key) => {
|
2019-11-13 13:42:34 -05:00
|
|
|
const value = headerEntriesDict[key];
|
|
|
|
const newkey = key.toLowerCase();
|
|
|
|
headerEntriesDict[newkey] = value;
|
|
|
|
});
|
2018-11-02 21:43:37 -04:00
|
|
|
let callNum = 0;
|
2021-08-05 07:08:58 -04:00
|
|
|
headers.forEach((value, key, container) => {
|
2019-11-13 13:42:34 -05:00
|
|
|
assertEquals(headers, container);
|
|
|
|
assertEquals(value, headerEntriesDict[key]);
|
|
|
|
callNum++;
|
|
|
|
});
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(callNum, keys.length);
|
2018-11-02 21:43:37 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerSymbolIteratorSuccess() {
|
2018-11-02 21:43:37 -04:00
|
|
|
assert(Symbol.iterator in Headers.prototype);
|
|
|
|
const headers = new Headers(headerEntriesDict);
|
|
|
|
for (const header of headers) {
|
|
|
|
const key = header[0];
|
|
|
|
const value = header[1];
|
|
|
|
assert(headers.has(key));
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(value, headers.get(key));
|
2018-11-02 21:43:37 -04:00
|
|
|
}
|
|
|
|
});
|
2018-11-08 19:09:18 -05:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerTypesAvailable() {
|
2018-11-08 19:09:18 -05:00
|
|
|
function newHeaders(): Headers {
|
|
|
|
return new Headers();
|
|
|
|
}
|
|
|
|
const headers = newHeaders();
|
|
|
|
assert(headers instanceof Headers);
|
|
|
|
});
|
2018-12-19 02:57:23 -05:00
|
|
|
|
|
|
|
// Modified from https://github.com/bitinn/node-fetch/blob/7d3293200a91ad52b5ca7962f9d6fd1c04983edb/test/test.js#L2001-L2014
|
|
|
|
// Copyright (c) 2016 David Frank. MIT License.
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerIllegalReject() {
|
2018-12-19 02:57:23 -05:00
|
|
|
let errorCount = 0;
|
|
|
|
try {
|
|
|
|
new Headers({ "He y": "ok" });
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
new Headers({ "Hé-y": "ok" });
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
new Headers({ "He-y": "ăk" });
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
const headers = new Headers();
|
|
|
|
try {
|
|
|
|
headers.append("Hé-y", "ok");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
headers.delete("Hé-y");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
headers.get("Hé-y");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
headers.has("Hé-y");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
headers.set("Hé-y", "ok");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-19 02:57:23 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
2018-12-29 07:30:11 -05:00
|
|
|
try {
|
|
|
|
headers.set("", "ok");
|
2021-04-09 17:35:29 -04:00
|
|
|
} catch (_e) {
|
2018-12-29 07:30:11 -05:00
|
|
|
errorCount++;
|
|
|
|
}
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(errorCount, 9);
|
2018-12-19 02:57:23 -05:00
|
|
|
// 'o k' is valid value but invalid name
|
|
|
|
new Headers({ "He-y": "o k" });
|
|
|
|
});
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2018-12-29 07:30:11 -05:00
|
|
|
// If pair does not contain exactly two items,then throw a TypeError.
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerParamsShouldThrowTypeError() {
|
2018-12-29 07:30:11 -05:00
|
|
|
let hasThrown = 0;
|
|
|
|
|
|
|
|
try {
|
|
|
|
new Headers(([["1"]] as unknown) as Array<[string, string]>);
|
|
|
|
hasThrown = 1;
|
|
|
|
} catch (err) {
|
|
|
|
if (err instanceof TypeError) {
|
|
|
|
hasThrown = 2;
|
|
|
|
} else {
|
|
|
|
hasThrown = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-06 20:48:46 -05:00
|
|
|
assertEquals(hasThrown, 2);
|
2018-12-29 07:30:11 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headerParamsArgumentsCheck() {
|
2020-06-02 00:24:44 -04:00
|
|
|
const methodRequireOneParam = ["delete", "get", "has", "forEach"] as const;
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2020-06-02 00:24:44 -04:00
|
|
|
const methodRequireTwoParams = ["append", "set"] as const;
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2021-08-05 07:08:58 -04:00
|
|
|
methodRequireOneParam.forEach((method) => {
|
2019-11-13 13:42:34 -05:00
|
|
|
const headers = new Headers();
|
|
|
|
let hasThrown = 0;
|
|
|
|
try {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
(headers as any)[method]();
|
2019-11-13 13:42:34 -05:00
|
|
|
hasThrown = 1;
|
|
|
|
} catch (err) {
|
|
|
|
if (err instanceof TypeError) {
|
|
|
|
hasThrown = 2;
|
|
|
|
} else {
|
|
|
|
hasThrown = 3;
|
2018-12-26 21:12:55 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-13 13:42:34 -05:00
|
|
|
assertEquals(hasThrown, 2);
|
|
|
|
});
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2021-08-05 07:08:58 -04:00
|
|
|
methodRequireTwoParams.forEach((method) => {
|
2019-11-13 13:42:34 -05:00
|
|
|
const headers = new Headers();
|
|
|
|
let hasThrown = 0;
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2019-11-13 13:42:34 -05:00
|
|
|
try {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
(headers as any)[method]();
|
2019-11-13 13:42:34 -05:00
|
|
|
hasThrown = 1;
|
|
|
|
} catch (err) {
|
|
|
|
if (err instanceof TypeError) {
|
|
|
|
hasThrown = 2;
|
|
|
|
} else {
|
|
|
|
hasThrown = 3;
|
2018-12-26 21:12:55 -05:00
|
|
|
}
|
2019-11-13 13:42:34 -05:00
|
|
|
}
|
|
|
|
assertEquals(hasThrown, 2);
|
2018-12-26 21:12:55 -05:00
|
|
|
|
2019-11-13 13:42:34 -05:00
|
|
|
hasThrown = 0;
|
|
|
|
try {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
(headers as any)[method]("foo");
|
2019-11-13 13:42:34 -05:00
|
|
|
hasThrown = 1;
|
|
|
|
} catch (err) {
|
|
|
|
if (err instanceof TypeError) {
|
|
|
|
hasThrown = 2;
|
|
|
|
} else {
|
|
|
|
hasThrown = 3;
|
2018-12-26 21:12:55 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-13 13:42:34 -05:00
|
|
|
assertEquals(hasThrown, 2);
|
|
|
|
});
|
2018-12-26 21:12:55 -05:00
|
|
|
});
|
2019-04-03 08:41:05 -04:00
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headersInitMultiple() {
|
2020-05-09 13:20:18 -04:00
|
|
|
const headers = new Headers([
|
|
|
|
["Set-Cookie", "foo=bar"],
|
|
|
|
["Set-Cookie", "bar=baz"],
|
|
|
|
["X-Deno", "foo"],
|
|
|
|
["X-Deno", "bar"],
|
|
|
|
]);
|
|
|
|
const actual = [...headers];
|
|
|
|
assertEquals(actual, [
|
|
|
|
["set-cookie", "foo=bar"],
|
|
|
|
["set-cookie", "bar=baz"],
|
|
|
|
["x-deno", "foo, bar"],
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headersAppendMultiple() {
|
2020-05-09 13:20:18 -04:00
|
|
|
const headers = new Headers([
|
|
|
|
["Set-Cookie", "foo=bar"],
|
|
|
|
["X-Deno", "foo"],
|
|
|
|
]);
|
|
|
|
headers.append("set-Cookie", "bar=baz");
|
|
|
|
headers.append("x-Deno", "bar");
|
|
|
|
const actual = [...headers];
|
|
|
|
assertEquals(actual, [
|
|
|
|
["set-cookie", "foo=bar"],
|
|
|
|
["set-cookie", "bar=baz"],
|
2021-04-18 19:00:13 -04:00
|
|
|
["x-deno", "foo, bar"],
|
2020-05-09 13:20:18 -04:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headersAppendDuplicateSetCookieKey() {
|
2020-05-09 13:20:18 -04:00
|
|
|
const headers = new Headers([["Set-Cookie", "foo=bar"]]);
|
|
|
|
headers.append("set-Cookie", "foo=baz");
|
|
|
|
headers.append("Set-cookie", "baz=bar");
|
|
|
|
const actual = [...headers];
|
|
|
|
assertEquals(actual, [
|
2021-04-18 19:00:13 -04:00
|
|
|
["set-cookie", "foo=bar"],
|
2020-05-09 13:20:18 -04:00
|
|
|
["set-cookie", "foo=baz"],
|
|
|
|
["set-cookie", "baz=bar"],
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function headersGetSetCookie() {
|
2020-05-09 13:20:18 -04:00
|
|
|
const headers = new Headers([
|
|
|
|
["Set-Cookie", "foo=bar"],
|
|
|
|
["set-Cookie", "bar=qat"],
|
|
|
|
]);
|
|
|
|
assertEquals(headers.get("SET-COOKIE"), "foo=bar, bar=qat");
|
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function toStringShouldBeWebCompatibility() {
|
2019-04-03 08:41:05 -04:00
|
|
|
const headers = new Headers();
|
|
|
|
assertEquals(headers.toString(), "[object Headers]");
|
|
|
|
});
|
2019-10-28 12:23:39 -04:00
|
|
|
|
|
|
|
function stringify(...args: unknown[]): string {
|
2020-07-11 00:52:18 -04:00
|
|
|
return inspectArgs(args).replace(/\n$/, "");
|
2019-10-28 12:23:39 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function customInspectReturnsCorrectHeadersFormat() {
|
2019-10-28 12:23:39 -04:00
|
|
|
const blankHeaders = new Headers();
|
|
|
|
assertEquals(stringify(blankHeaders), "Headers {}");
|
|
|
|
const singleHeader = new Headers([["Content-Type", "application/json"]]);
|
|
|
|
assertEquals(
|
|
|
|
stringify(singleHeader),
|
2021-04-18 19:00:13 -04:00
|
|
|
`Headers { "content-type": "application/json" }`,
|
2019-10-28 12:23:39 -04:00
|
|
|
);
|
|
|
|
const multiParamHeader = new Headers([
|
|
|
|
["Content-Type", "application/json"],
|
2020-03-28 13:03:49 -04:00
|
|
|
["Content-Length", "1337"],
|
2019-10-28 12:23:39 -04:00
|
|
|
]);
|
|
|
|
assertEquals(
|
|
|
|
stringify(multiParamHeader),
|
2021-04-18 19:00:13 -04:00
|
|
|
`Headers { "content-length": "1337", "content-type": "application/json" }`,
|
2019-10-28 12:23:39 -04:00
|
|
|
);
|
|
|
|
});
|
2022-10-10 12:06:50 -04:00
|
|
|
|
|
|
|
Deno.test(function invalidHeadersFlaky() {
|
|
|
|
assertThrows(
|
|
|
|
() => new Headers([["x", "\u0000x"]]),
|
|
|
|
TypeError,
|
|
|
|
"Header value is not valid.",
|
|
|
|
);
|
|
|
|
assertThrows(
|
|
|
|
() => new Headers([["x", "\u0000x"]]),
|
|
|
|
TypeError,
|
|
|
|
"Header value is not valid.",
|
|
|
|
);
|
|
|
|
});
|