runservice: use the path escaped cache key

Use the path escaped cache key so we can also handle cache keys with slashes
inside.
This commit is contained in:
Simone Gotti 2019-05-08 12:15:17 +02:00
parent bec9476d6c
commit ce7924d7fd
1 changed files with 6 additions and 11 deletions

View File

@ -20,7 +20,6 @@ import (
"encoding/json"
"io"
"net/http"
"net/url"
"strconv"
"github.com/gorilla/mux"
@ -273,11 +272,9 @@ func NewCacheHandler(logger *zap.Logger, ost *objectstorage.ObjStorage) *CacheHa
func (h *CacheHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
// TODO(sgotti) Check authorized call from executors
key, err := url.PathUnescape(vars["key"])
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// keep and use the escaped path
key := vars["key"]
if key == "" {
http.Error(w, "empty cache key", http.StatusBadRequest)
return
@ -384,11 +381,9 @@ func NewCacheCreateHandler(logger *zap.Logger, ost *objectstorage.ObjStorage) *C
func (h *CacheCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
// TODO(sgotti) Check authorized call from executors
key, err := url.PathUnescape(vars["key"])
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// keep and use the escaped path
key := vars["key"]
if key == "" {
http.Error(w, "empty cache key", http.StatusBadRequest)
return