mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): pass content-disposition header as string instead of bytes (#25128)
Closes https://github.com/denoland/deno/issues/25117
This commit is contained in:
parent
dd8a9c509f
commit
e920835417
2 changed files with 28 additions and 1 deletions
|
@ -906,7 +906,7 @@ class ClientRequest extends OutgoingMessage {
|
||||||
// https://www.rfc-editor.org/rfc/rfc6266#section-4.3
|
// https://www.rfc-editor.org/rfc/rfc6266#section-4.3
|
||||||
// Refs: https://github.com/nodejs/node/pull/46528
|
// Refs: https://github.com/nodejs/node/pull/46528
|
||||||
if (isContentDispositionField(key) && this._contentLength) {
|
if (isContentDispositionField(key) && this._contentLength) {
|
||||||
value = Buffer.from(value, "latin1");
|
value = Buffer.from(value).toString("latin1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
|
|
|
@ -1559,3 +1559,30 @@ Deno.test("[node/http] req.url equals pathname + search", async () => {
|
||||||
|
|
||||||
await promise;
|
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");
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue