[ARVADOS] created: ea8c290061e4ecc80d5d113debe6681090cf6594

git at public.curoverse.com git at public.curoverse.com
Mon May 11 16:38:53 EDT 2015


        at  ea8c290061e4ecc80d5d113debe6681090cf6594 (commit)


commit ea8c290061e4ecc80d5d113debe6681090cf6594
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon May 11 16:38:23 2015 -0400

    5992: keepproxy strips +K@{5} hints from locators before trying GET.  +K at 5-5-15
    locators are preserved.

diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index ebdb6eb..d0af4a5 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -15,6 +15,7 @@ import (
 	"os"
 	"os/signal"
 	"reflect"
+	"regexp"
 	"sync"
 	"syscall"
 	"time"
@@ -297,6 +298,8 @@ var BadAuthorizationHeader = errors.New("Missing or invalid Authorization header
 var ContentLengthMismatch = errors.New("Actual length != expected content length")
 var MethodNotSupported = errors.New("Method not supported")
 
+var removeHint, _ = regexp.Compile("\\+K@[a-z0-9]{5}(\\+|$)")
+
 func (this GetBlockHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
 	SetCorsHeaders(resp)
 
@@ -329,6 +332,8 @@ func (this GetBlockHandler) ServeHTTP(resp http.ResponseWriter, req *http.Reques
 
 	var reader io.ReadCloser
 
+	locator = removeHint.ReplaceAllString(locator, "$1")
+
 	switch req.Method {
 	case "HEAD":
 		expectLength, proxiedURI, err = kc.Ask(locator)
diff --git a/services/keepproxy/keepproxy_test.go b/services/keepproxy/keepproxy_test.go
index 5f6e2b9..a04e9fb 100644
--- a/services/keepproxy/keepproxy_test.go
+++ b/services/keepproxy/keepproxy_test.go
@@ -386,3 +386,19 @@ func (s *ServerRequiredSuite) TestPostWithoutHash(c *C) {
 			fmt.Sprintf("%x+%d", md5.Sum([]byte("qux")), 3))
 	}
 }
+
+func (s *ServerRequiredSuite) TestStripHint(c *C) {
+	c.Check(removeHint.ReplaceAllString("http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73+K@zzzzz", "$1"),
+		Equals,
+		"http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73")
+	c.Check(removeHint.ReplaceAllString("http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+K@zzzzz+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73", "$1"),
+		Equals,
+		"http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73")
+	c.Check(removeHint.ReplaceAllString("http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73+K@zzzzz-zzzzz-zzzzzzzzzzzzzzz", "$1"),
+		Equals,
+		"http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73+K@zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+	c.Check(removeHint.ReplaceAllString("http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+K@zzzzz-zzzzz-zzzzzzzzzzzzzzz+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73", "$1"),
+		Equals,
+		"http://keep.zzzzz.arvadosapi.com:25107/2228819a18d3727630fa30c81853d23f+67108864+K@zzzzz-zzzzz-zzzzzzzzzzzzzzz+A37b6ab198qqqq28d903b975266b23ee711e1852c@55635f73")
+
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list