Bun.serve({
fetch(req: Request) {
const file = Bun.file("test.css");
// The response *will* include the Date header.
return new Response(file, {
headers: {
"hello-world": "yes",
},
});
// The response *will not* include the Date header.
return new Response(file);
},
port: 8080,
});
Additional information
The RFC 7231 for HTTP/1.1 states that the Date header should always be included except for in these cases:
If the response status code is 100 (Continue) or 101 (Switching Protocols).
If the response has no content-body and the request method was HEAD."
What version of Bun is running?
1.1.10-canary.1+34b02ada1
What platform is your computer?
Linux 6.8.0-31-generic x86_64 x86_64
What steps can reproduce the bug?
Additional information
The RFC 7231 for HTTP/1.1 states that the Date header should always be included except for in these cases:
Where it's being added: https://github.com/oven-sh/bun/blob/912bccb6243bbc169c0d92e23dc1be7f01e44fba/packages/bun-uws/src/HttpResponse.h#L77
It seems like the Bun.file path with no additional headers is stripping/bypassing that code.