diff --git a/README.md b/README.md index 8cb3ddc..c5fb3c6 100644 --- a/README.md +++ b/README.md @@ -129,16 +129,16 @@ Host: tus.example.com HTTP/1.1 200 Ok Content-Length: 100 Content-Type: image/jpg -X-Missing: bytes=20-50,60-99 +Range: bytes=0-20,40-99 ``` -The `X-Missing` header holds a [byte +The `Range` header holds a [byte range](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1) that -informs the client which parts of the file have not been received yet. It is +informs the client which parts of the file have been received so far. It is up to the client to choose appropiate `PUT` requests to complete the upload. -The absence of a `X-Missing` header means that the the entire file has been -received by the server. +A completed upload will be indicated by a single range covering the entire file +size (e.g. `Range: bytes=0-99` for a 100 byte file). ### GET \ diff --git a/src/cmd/tusd/data.go b/src/cmd/tusd/data.go index 756761b..3da2227 100644 --- a/src/cmd/tusd/data.go +++ b/src/cmd/tusd/data.go @@ -123,23 +123,3 @@ func getReceivedChunks(fileId string) (chunkSet, error) { return chunks, nil } - -func getMissingChunks(fileId string) (chunkSet, error) { - d := dataPath(fileId) - stat, err := os.Stat(d) - if err != nil { - return nil, err - } - - receivedChunks, err := getReceivedChunks(fileId) - if err != nil { - return nil, err - } - - // @TODO actually calcuate missing chunks instead of received - _ = stat - - //chunks := chunkSet{{Start: 0, End: stat.Size()-1}} - //chunks := make(chunkSet, 0) - return receivedChunks, nil -} diff --git a/src/cmd/tusd/http.go b/src/cmd/tusd/http.go index c51b94d..3aa16cb 100644 --- a/src/cmd/tusd/http.go +++ b/src/cmd/tusd/http.go @@ -102,21 +102,21 @@ func putFile(w http.ResponseWriter, r *http.Request, fileId string) { } func headFile(w http.ResponseWriter, r *http.Request, fileId string) { - chunks, err := getMissingChunks(fileId) + chunks, err := getReceivedChunks(fileId) if err != nil { reply(w, http.StatusInternalServerError, err.Error()) return } - missing := "" + received := "" for i, chunk := range chunks { - missing += fmt.Sprintf("%d-%d", chunk.Start, chunk.End) + received += fmt.Sprintf("%d-%d", chunk.Start, chunk.End) if i + 1 < len(chunks) { - missing += "," + received += "," } } - if missing != "" { - w.Header().Set("X-Missing", "bytes="+missing) + if received != "" { + w.Header().Set("Range", "bytes="+received) } }