Skip to content

Commit

Permalink
Fix livereload for static directory indexes
Browse files Browse the repository at this point in the history
Turns out that bytes.Buffer.Len only returns the _unread_ length of the buffer.
  • Loading branch information
cortesi committed Oct 23, 2015
1 parent 9ca8897 commit 7bc137d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fileserver/fileserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func dirList(ci inject.CopyInject, logger termlog.Logger, w http.ResponseWriter,
data := dirData{Name: name, Files: files}
buff := bytes.NewBuffer(make([]byte, 0, 0))
err = templates.Lookup("dirlist.html").Execute(buff, data)
length := buff.Len()
if err != nil {
logger.Shout("Error producing directory listing: %s", err)
}
Expand All @@ -60,7 +61,7 @@ func dirList(ci inject.CopyInject, logger termlog.Logger, w http.ResponseWriter,
return
}
w.Header().Set(
"Content-Length", fmt.Sprintf("%d", buff.Len()+inj.Extra()),
"Content-Length", fmt.Sprintf("%d", length+inj.Extra()),
)
_, err = inj.Copy(w)
if err != nil {
Expand Down

0 comments on commit 7bc137d

Please sign in to comment.