Skip to content

Commit aeda6b7

Browse files
committed
test: add a test-case for duplicate cookie headers
See 73af733
1 parent dd36b05 commit aeda6b7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/fetch.mjs

+29
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,34 @@ export default Test => [
271271
resolve(true);
272272
});
273273
});
274+
}),
275+
new Test("fetch(): no duplicate header on redirect", () => {
276+
const app = express();
277+
app.use(cookieParser());
278+
app.put("/", (request, response) => {
279+
response.cookie("foo", "bar");
280+
response.redirect(302, "/redirect");
281+
});
282+
app.put("/redirect", (request, response) => {
283+
response.cookie("foo2", "bar");
284+
response.redirect(303, "/redirect2");
285+
});
286+
app.get("/redirect2", (request, response) => {
287+
if (request.headers["cookie"].split("foo=bar").length > 2) {
288+
response.status(400);
289+
}
290+
response.send();
291+
});
292+
return new Promise(resolve => {
293+
const server = app.listen(0, async () => {
294+
const cookieJar = new CookieJar();
295+
const response = await fetch(cookieJar, `http://localhost:${server.address().port}/`, {
296+
method: "PUT"
297+
});
298+
server.close();
299+
resolve(response.ok);
300+
});
301+
302+
});
274303
})
275304
];

0 commit comments

Comments
 (0)