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:
parent
bec9476d6c
commit
ce7924d7fd
|
@ -20,7 +20,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"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) {
|
func (h *CacheHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
// TODO(sgotti) Check authorized call from executors
|
// TODO(sgotti) Check authorized call from executors
|
||||||
key, err := url.PathUnescape(vars["key"])
|
|
||||||
if err != nil {
|
// keep and use the escaped path
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
key := vars["key"]
|
||||||
return
|
|
||||||
}
|
|
||||||
if key == "" {
|
if key == "" {
|
||||||
http.Error(w, "empty cache key", http.StatusBadRequest)
|
http.Error(w, "empty cache key", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
@ -384,11 +381,9 @@ func NewCacheCreateHandler(logger *zap.Logger, ost *objectstorage.ObjStorage) *C
|
||||||
func (h *CacheCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *CacheCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
// TODO(sgotti) Check authorized call from executors
|
// TODO(sgotti) Check authorized call from executors
|
||||||
key, err := url.PathUnescape(vars["key"])
|
|
||||||
if err != nil {
|
// keep and use the escaped path
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
key := vars["key"]
|
||||||
return
|
|
||||||
}
|
|
||||||
if key == "" {
|
if key == "" {
|
||||||
http.Error(w, "empty cache key", http.StatusBadRequest)
|
http.Error(w, "empty cache key", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue