X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8af4c5ffe2d0bf7f009f8821945aa100ddf02279..200f7004f921a68ec40b407dfe31f1db95e98fb9:/services/keepstore/handlers.go diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go index f462b0aae1..6492045c68 100644 --- a/services/keepstore/handlers.go +++ b/services/keepstore/handlers.go @@ -160,6 +160,11 @@ func PutBlockHandler(resp http.ResponseWriter, req *http.Request) { // the body: avoid transmitting data that will not end up // being written anyway. + if req.ContentLength == -1 { + http.Error(resp, SizeRequiredError.Error(), SizeRequiredError.HTTPCode) + return + } + if req.ContentLength > BLOCKSIZE { http.Error(resp, TooLongError.Error(), TooLongError.HTTPCode) return @@ -192,7 +197,7 @@ func PutBlockHandler(resp http.ResponseWriter, req *http.Request) { return_hash := fmt.Sprintf("%s+%d", hash, len(buf)) api_token := GetApiToken(req) if PermissionSecret != nil && api_token != "" { - expiry := time.Now().Add(permission_ttl) + expiry := time.Now().Add(blob_signature_ttl) return_hash = SignLocator(return_hash, api_token, expiry) } resp.Write([]byte(return_hash + "\n")) @@ -210,11 +215,18 @@ func IndexHandler(resp http.ResponseWriter, req *http.Request) { prefix := mux.Vars(req)["prefix"] - var index string for _, vol := range KeepVM.AllReadable() { - index = index + vol.Index(prefix) + if err := vol.IndexTo(prefix, resp); err != nil { + // The only errors returned by IndexTo are + // write errors returned by resp.Write(), + // which probably means the client has + // disconnected and this error will never be + // reported to the client -- but it will + // appear in our own error log. + http.Error(resp, err.Error(), http.StatusInternalServerError) + return + } } - resp.Write([]byte(index)) } // StatusHandler