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

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
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 return
} }
if len(xHeaders)%2 != 0 {
panic("slice of X-Headers with odd length")
}
hs := make([]v2session.XHeader, len(xHeaders)/2) hs := make([]v2session.XHeader, len(xHeaders)/2)
for i := 0; i < len(xHeaders); i += 2 { for i := 0; i < len(xHeaders); i += 2 {
hs[i].SetKey(xHeaders[i]) 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. // Slice must not be mutated until the operation completes.
func (x *PrmObjectDelete) WithXHeaders(hs ...string) { func (x *PrmObjectDelete) WithXHeaders(hs ...string) {
if len(hs)%2 != 0 {
panic("slice of X-Headers with odd length")
}
writeXHeadersToMeta(hs, &x.meta) writeXHeadersToMeta(hs, &x.meta)
} }

View file

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

View file

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