12447: Simplify BlockCache locking.
[arvados.git] / sdk / go / keepclient / keepclient.go
index 8b518ac8d51a2858980441ac0a2c81993bbc9436..cbfad8177da775337bf2b528a99ff9a0757cbaa0 100644 (file)
@@ -246,6 +246,10 @@ func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, i
                                } else if resp.StatusCode == 404 {
                                        count404++
                                }
+                       } else if resp.ContentLength < 0 {
+                               // Missing Content-Length
+                               resp.Body.Close()
+                               return nil, 0, "", fmt.Errorf("Missing Content-Length of block")
                        } else {
                                // Success.
                                if method == "GET" {
@@ -434,6 +438,10 @@ func (kc *KeepClient) cache() *BlockCache {
        }
 }
 
+func (kc *KeepClient) ClearBlockCache() {
+       kc.cache().Clear()
+}
+
 var (
        // There are four global http.Client objects for the four
        // possible permutations of TLS behavior (verify/skip-verify)