mirror of
https://github.com/denoland/deno.git
synced 2024-11-30 16:40:57 -05:00
set content-length for bodyless response
This commit is contained in:
parent
958dadc875
commit
0e82a4249e
1 changed files with 6 additions and 7 deletions
13
http.ts
13
http.ts
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue