merge nested hash readers (#9582)

The `ioutil.NopCloser(reader)` was hiding nested hash readers.

We make it an `io.Closer` so it can be attached without wrapping 
and allows for nesting, by merging the requests.
This commit is contained in:
Klaus Post
2020-05-14 23:01:31 +02:00
committed by GitHub
parent a9558ae248
commit 216fa57b88
6 changed files with 258 additions and 73 deletions

View File

@@ -16,6 +16,8 @@
package hash
import "fmt"
// SHA256Mismatch - when content sha256 does not match with what was sent from client.
type SHA256Mismatch struct {
ExpectedSHA256 string
@@ -23,7 +25,7 @@ type SHA256Mismatch struct {
}
func (e SHA256Mismatch) Error() string {
return "Bad sha256: Expected " + e.ExpectedSHA256 + " is not valid with what we calculated " + e.CalculatedSHA256
return "Bad sha256: Expected " + e.ExpectedSHA256 + " does not match calculated " + e.CalculatedSHA256
}
// BadDigest - Content-MD5 you specified did not match what we received.
@@ -33,5 +35,14 @@ type BadDigest struct {
}
func (e BadDigest) Error() string {
return "Bad digest: Expected " + e.ExpectedMD5 + " is not valid with what we calculated " + e.CalculatedMD5
return "Bad digest: Expected " + e.ExpectedMD5 + " does not match calculated " + e.CalculatedMD5
}
type ErrSizeMismatch struct {
Want int64
Got int64
}
func (e ErrSizeMismatch) Error() string {
return fmt.Sprintf("Size mismatch: got %d, want %d", e.Got, e.Want)
}