serve http: added content-length header when html directory is served

This commit is contained in:
Sunny 2024-05-14 00:24:54 +08:00 committed by GitHub
parent 1890608f55
commit 6356b51b33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,6 +235,7 @@ func (d *Directory) Serve(w http.ResponseWriter, r *http.Request) {
Error(d.DirRemote, w, "Failed to render template", err)
return
}
w.Header().Set("Content-Length", fmt.Sprintf("%d", buf.Len()))
_, err = buf.WriteTo(w)
if err != nil {
Error(d.DirRemote, nil, "Failed to drain template buffer", err)