diff --git a/lxd/instance_file.go b/lxd/instance_file.go index 8bea4bf480b2..0dd87b4993b0 100644 --- a/lxd/instance_file.go +++ b/lxd/instance_file.go @@ -176,7 +176,7 @@ func instanceFileGet(s *state.State, inst instance.Instance, path string, r *htt fileType = "symlink" } - fs := stat.Sys().(*sftp.FileStat) + fs, _ := stat.Sys().(*sftp.FileStat) // Prepare the response. headers := map[string]string{ @@ -339,7 +339,7 @@ func instanceFileHead(inst instance.Instance, path string) response.Response { fileType = "symlink" } - fs := stat.Sys().(*sftp.FileStat) + fs, _ := stat.Sys().(*sftp.FileStat) // Prepare the response. headers := map[string]string{ @@ -350,6 +350,11 @@ func instanceFileHead(inst instance.Instance, path string) response.Response { "X-LXD-type": fileType, } + if fileType == "file" { + headers["Content-Type"] = "application/octet-stream" + headers["Content-Length"] = fmt.Sprintf("%d", stat.Size()) + } + // Return an empty body (per RFC for HEAD). return response.ManualResponse(func(w http.ResponseWriter) error { // Set the headers.