summaryrefslogtreecommitdiff
path: root/tests/unit_node/http_test.ts
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-08-21 15:43:17 +0530
committerGitHub <noreply@github.com>2024-08-21 10:13:17 +0000
commite920835417d10f3735645c910e513886cdda6a39 (patch)
tree213bca388ea9f05135b907d5cad18feede0328b1 /tests/unit_node/http_test.ts
parentdd8a9c509f0c7c643f60e4b5aee6233383e0dc80 (diff)
fix(ext/node): pass content-disposition header as string instead of bytes (#25128)
Closes https://github.com/denoland/deno/issues/25117
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r--tests/unit_node/http_test.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts
index 2043a0004..a599754b9 100644
--- a/tests/unit_node/http_test.ts
+++ b/tests/unit_node/http_test.ts
@@ -1559,3 +1559,30 @@ Deno.test("[node/http] req.url equals pathname + search", async () => {
await promise;
});
+
+Deno.test("[node/http] ClientRequest content-disposition header works", async () => {
+ const payload = Buffer.from("hello world");
+ let body = "";
+ let headers = {} as http.IncomingHttpHeaders;
+ const { promise, resolve, reject } = Promise.withResolvers<void>();
+ const req = http.request("http://localhost:4545/echo_server", {
+ method: "PUT",
+ headers: {
+ "content-disposition": "attachment",
+ },
+ }, (resp) => {
+ headers = resp.headers;
+ resp.on("data", (chunk) => {
+ body += chunk;
+ });
+
+ resp.on("end", () => {
+ resolve();
+ });
+ });
+ req.once("error", (e) => reject(e));
+ req.end(payload);
+ await promise;
+ assertEquals(body, "hello world");
+ assertEquals(headers["content-disposition"], "attachment");
+});