h3
h3 copied to clipboard
bun sets default `content-type` for Uint8Array
Environment
using h3 v2 directly from repo "./src/index.ts" and bun 1.2.18
Reproduction
import { H3, serve } from "./src/index.ts";
const app = new H3();
app.get("/", (e) => {
return new TextEncoder().encode("hello");
});
console.log(
await fetch(serve(app).url!).then((r) => r.headers.get("content-type")),
);
Describe the bug
application/octet-stream is unexpected. when opening in a browser it downloads a file.
Additional context
in node it doesn't download and content-type is null
Logs
export default {
fetch(req) {
return new Response(new TextEncoder().encode("hello"));
},
};
Running this in bun > curl -v localhost:3000:
< HTTP/1.1 200 OK
< content-type: application/octet-stream
Running the same code in Deno, does not set content-type
Also running a normal Node.js server, does not sets content-type
new Server((req, res) => {
res.end(new TextEncoder().encode("hello"));
}).listen(3000);
It is a Bun-specific behavior and has nothing to do with H3 or Srvx. I think we should report it in Bun as a bug and mismatching behavior with all other runtimes.