1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00

set content-length for bodyless response

Original: 0e82a4249e
This commit is contained in:
Bartek Iwańczuk 2018-12-09 18:44:13 +01:00 committed by Ryan Dahl
parent 2516281306
commit 2b360c60a5

13
http.ts
View file

@ -89,13 +89,12 @@ interface Response {
}
function setContentLength(r: Response): void {
if (r.body) {
if (!r.headers) {
r.headers = new Headers();
}
if (!r.headers.has("content-length")) {
r.headers.append("Content-Length", r.body.byteLength.toString());
}
if (!r.headers) {
r.headers = new Headers();
}
if (!r.headers.has("content-length")) {
const bodyLength = r.body ? r.body.byteLength : 0
r.headers.append("Content-Length", bodyLength.toString());
}
}