// 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
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"))
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