[ARVADOS] updated: d53271e587b7bdbfe37b8ae8eaf890dd69c2796b
git at public.curoverse.com
git at public.curoverse.com
Tue Sep 29 22:21:41 EDT 2015
Summary of changes:
sdk/go/keepclient/keepclient.go | 29 ++++++++++++++++-------------
services/keepproxy/keepproxy.go | 5 +----
2 files changed, 17 insertions(+), 17 deletions(-)
via d53271e587b7bdbfe37b8ae8eaf890dd69c2796b (commit)
from a72b3d08c70f615c5a67ffd4cf816e5502edd629 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit d53271e587b7bdbfe37b8ae8eaf890dd69c2796b
Author: radhika <radhika at curoverse.com>
Date: Tue Sep 29 22:19:42 2015 -0400
7200: no need to set content length header in keepproxy IndexHandler since the response is always terminated by a blank new line.
diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index 314ebd5..541ca68 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -191,8 +191,10 @@ func (kc *KeepClient) Ask(locator string) (int64, string, error) {
// GetIndex retrieves a list of blocks stored on the given server whose hashes
// begin with the given prefix. The returned reader will return an error (other
-// than EOF) if the complete index cannot be retrieved. This should only be
-// expected to return useful results if the client is using a "data manager token"
+// than EOF) if the complete index cannot be retrieved.
+//
+// This is meant to be used only by system components and admin tools.
+// It will return an error unless the client is using a "data manager token"
// recognized by the Keep services.
func (kc *KeepClient) GetIndex(keepServiceUUID, prefix string) (io.Reader, error) {
url := kc.LocalRoots()[keepServiceUUID]
@@ -215,23 +217,24 @@ func (kc *KeepClient) GetIndex(keepServiceUUID, prefix string) (io.Reader, error
if err != nil {
return nil, err
}
+
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Got http status code: %d", resp.StatusCode)
}
+ defer resp.Body.Close()
+
var respBody []byte
- if resp.Body != nil {
- respBody, err = ioutil.ReadAll(resp.Body)
- if err != nil {
- return nil, err
- }
+ respBody, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return nil, err
+ }
- // Got index; verify that it is complete
- // The response should be "\n" if no locators matched the prefix
- // Else, it should be a list of locators followed by a blank line
- if !bytes.Equal(respBody, []byte("\n")) && !bytes.HasSuffix(respBody, []byte("\n\n")) {
- return nil, ErrIncompleteIndex
- }
+ // Got index; verify that it is complete
+ // The response should be "\n" if no locators matched the prefix
+ // Else, it should be a list of locators followed by a blank line
+ if !bytes.Equal(respBody, []byte("\n")) && !bytes.HasSuffix(respBody, []byte("\n\n")) {
+ return nil, ErrIncompleteIndex
}
// Got complete index; strip the trailing newline and send
diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index 461e99d..f2a93f1 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -533,7 +533,6 @@ func (handler IndexHandler) ServeHTTP(resp http.ResponseWriter, req *http.Reques
return
}
- contentLen := 0
var reader io.Reader
for uuid := range kc.LocalRoots() {
reader, err = kc.GetIndex(uuid, prefix)
@@ -550,16 +549,14 @@ func (handler IndexHandler) ServeHTTP(resp http.ResponseWriter, req *http.Reques
}
// Got index for this server; write to resp
- n, err := resp.Write(readBytes)
+ _, err := resp.Write(readBytes)
if err != nil {
status = http.StatusBadGateway
return
}
- contentLen += n
}
// Got index from all the keep servers and wrote to resp
status = http.StatusOK
- resp.Header().Set("Content-Length", fmt.Sprint(contentLen+1))
resp.Write([]byte("\n"))
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list