Permalink
Browse files

Improve comments.

Change-Id: I09ad28be36050e22acb0b1b2c7d00dd2bcd61671
  • Loading branch information...
1 parent be2e091 commit 4e5fba8758bf962786ef8e1176ce87cd154424ca @kowshik kowshik committed Oct 3, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 go/src/directoryserver/directoryserver.go
@@ -8,7 +8,7 @@
Directory listing lists sub-directories and files contained inside the
directory along with the file sizes. Streaming of files uses HTTP chunked
- transfer encoding.
+ transfer encoding. The server also handles HTTP byte range requests.
*/
package directoryserver
@@ -124,8 +124,8 @@ func (h handler) listDir(writer http.ResponseWriter, dirPath string) {
}
// Dumps the contents of the specified file in the HTTP response.
-// Also handles HTTP range requests.
-// Returns an error if there is a problem in reading the file.
+// Also handles HTTP byte range requests.
+// Returns an error if there is a problem in opening/closing the file.
func (h handler) dumpFile(request *http.Request, writer http.ResponseWriter,
path string) error {
info, err := os.Stat(path)
@@ -138,6 +138,8 @@ func (h handler) dumpFile(request *http.Request, writer http.ResponseWriter,
return err
}
+ // This takes care of serving HTTP byte range request if present.
+ // Otherwise dumps the entire file in the HTTP response.
http.ServeContent(writer, request, path, info.ModTime(), handle)
return handle.Close()
}

0 comments on commit 4e5fba8

Please sign in to comment.