[#323] client: Remove xheaders length check in a common helper

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
remotes/fyrchik/maintenance
Evgenii Stratonikov 2022-08-26 13:20:30 +03:00 committed by fyrchik
parent d6d6a41f5d
commit 0e4d07fb06
6 changed files with 4 additions and 20 deletions

View File

@ -57,6 +57,10 @@ func writeXHeadersToMeta(xHeaders []string, h *v2session.RequestMetaHeader) {
return
}
if len(xHeaders)%2 != 0 {
panic("slice of X-Headers with odd length")
}
hs := make([]v2session.XHeader, len(xHeaders)/2)
for i := 0; i < len(xHeaders); i += 2 {
hs[i].SetKey(xHeaders[i])

View File

@ -85,10 +85,6 @@ func (x *PrmObjectDelete) UseKey(key ecdsa.PrivateKey) {
//
// Slice must not be mutated until the operation completes.
func (x *PrmObjectDelete) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta)
}

View File

@ -36,10 +36,6 @@ type prmObjectRead struct {
//
// Slice must not be mutated until the operation completes.
func (x *prmObjectRead) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta)
}

View File

@ -116,10 +116,6 @@ func (x *PrmObjectHash) UseSalt(salt []byte) {
//
// Slice must not be mutated until the operation completes.
func (x *PrmObjectHash) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta)
}

View File

@ -102,10 +102,6 @@ func (x *PrmObjectPutInit) MarkLocal() {
//
// Slice must not be mutated until the operation completes.
func (x *PrmObjectPutInit) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta)
}

View File

@ -67,10 +67,6 @@ func (x *PrmObjectSearch) WithBearerToken(t bearer.Token) {
//
// Slice must not be mutated until the operation completes.
func (x *PrmObjectSearch) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta)
}