diff --git a/cmd/globals.go b/cmd/globals.go index 37afb39bf..5bd16fa0b 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -57,7 +57,6 @@ const ( globalMinioDefaultStorageClass = "STANDARD" globalWindowsOSName = "windows" globalNetBSDOSName = "netbsd" - globalSolarisOSName = "solaris" globalMinioModeFS = "mode-server-fs" globalMinioModeXL = "mode-server-xl" globalMinioModeDistXL = "mode-server-distributed-xl" diff --git a/cmd/posix.go b/cmd/posix.go index 7425c3142..003ebe0bf 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -232,7 +232,6 @@ func getDiskInfo(diskPath string) (di disk.Info, err error) { var ignoreDiskFreeOS = []string{ globalWindowsOSName, globalNetBSDOSName, - globalSolarisOSName, } // check if disk total has minimum required size. @@ -943,20 +942,6 @@ func (s *posix) openFile(volume, path string, mode int) (f *os.File, err error) return w, nil } -// Just like io.LimitedReader but supports Close() to be compatible with io.ReadCloser that is -// returned by posix.ReadFileStream() -type posixLimitedReader struct { - io.LimitedReader -} - -func (l *posixLimitedReader) Close() error { - c, ok := l.R.(io.Closer) - if !ok { - return errUnexpected - } - return c.Close() -} - // ReadFileStream - Returns the read stream of the file. func (s *posix) ReadFileStream(volume, path string, offset, length int64) (io.ReadCloser, error) { var err error @@ -1030,7 +1015,10 @@ func (s *posix) ReadFileStream(volume, path string, offset, length int64) (io.Re if _, err = file.Seek(offset, io.SeekStart); err != nil { return nil, err } - return &posixLimitedReader{io.LimitedReader{R: file, N: length}}, nil + return struct { + io.Reader + io.Closer + }{Reader: io.LimitReader(file, length), Closer: file}, nil } // CreateFile - creates the file. diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index 00c31d97f..8cf6b4eb9 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -47,6 +47,7 @@ type storageRESTServer struct { func (s *storageRESTServer) writeErrorResponse(w http.ResponseWriter, err error) { w.WriteHeader(http.StatusForbidden) w.Write([]byte(err.Error())) + w.(http.Flusher).Flush() } // Authenticates storage client's requests and validates for skewed time. @@ -93,6 +94,7 @@ func (s *storageRESTServer) GetInstanceID(w http.ResponseWriter, r *http.Request } w.Header().Set("Content-Length", strconv.Itoa(len(s.instanceID))) w.Write([]byte(s.instanceID)) + w.(http.Flusher).Flush() } // DiskInfoHandler - returns disk info. @@ -268,6 +270,7 @@ func (s *storageRESTServer) ReadAllHandler(w http.ResponseWriter, r *http.Reques } w.Header().Set("Content-Length", strconv.Itoa(len(buf))) w.Write(buf) + w.(http.Flusher).Flush() } // ReadFileHandler - read section of a file. @@ -311,6 +314,7 @@ func (s *storageRESTServer) ReadFileHandler(w http.ResponseWriter, r *http.Reque } w.Header().Set("Content-Length", strconv.Itoa(len(buf))) w.Write(buf) + w.(http.Flusher).Flush() } // ReadFileHandler - read section of a file. @@ -331,6 +335,7 @@ func (s *storageRESTServer) ReadFileStreamHandler(w http.ResponseWriter, r *http s.writeErrorResponse(w, err) return } + rc, err := s.storage.ReadFileStream(volume, filePath, int64(offset), int64(length)) if err != nil { s.writeErrorResponse(w, err) @@ -338,7 +343,9 @@ func (s *storageRESTServer) ReadFileStreamHandler(w http.ResponseWriter, r *http } defer rc.Close() w.Header().Set("Content-Length", strconv.Itoa(length)) + io.Copy(w, rc) + w.(http.Flusher).Flush() } // ListDirHandler - list a directory.