2020-10-02 12:23:52 +00:00
|
|
|
package v2
|
|
|
|
|
|
|
|
import (
|
2022-05-17 13:40:25 +00:00
|
|
|
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
|
|
|
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"
|
2020-10-02 12:23:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type xHeaderSource interface {
|
2022-05-17 13:40:25 +00:00
|
|
|
GetXHeaders() []eaclSDK.Header
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type requestXHeaderSource struct {
|
|
|
|
req Request
|
|
|
|
}
|
|
|
|
|
|
|
|
type responseXHeaderSource struct {
|
|
|
|
resp Response
|
2020-12-28 15:59:42 +00:00
|
|
|
|
|
|
|
req Request
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-17 13:40:25 +00:00
|
|
|
func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
2020-10-02 12:23:52 +00:00
|
|
|
ln := 0
|
|
|
|
|
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
2022-05-17 13:44:35 +00:00
|
|
|
ln += len(meta.GetXHeaders())
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-17 13:40:25 +00:00
|
|
|
res := make([]eaclSDK.Header, 0, ln)
|
2022-05-17 13:44:35 +00:00
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
|
|
x := meta.GetXHeaders()
|
|
|
|
for i := range x {
|
|
|
|
res = append(res, sessionSDK.NewXHeaderFromV2(&x[i]))
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2022-05-17 13:40:25 +00:00
|
|
|
func (s responseXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
2020-10-02 12:23:52 +00:00
|
|
|
ln := 0
|
|
|
|
|
2020-12-28 15:59:42 +00:00
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
2022-05-17 13:44:35 +00:00
|
|
|
ln += len(meta.GetXHeaders())
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-17 13:40:25 +00:00
|
|
|
res := make([]eaclSDK.Header, 0, ln)
|
2022-05-17 13:44:35 +00:00
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
|
|
x := meta.GetXHeaders()
|
|
|
|
for i := range x {
|
|
|
|
res = append(res, sessionSDK.NewXHeaderFromV2(&x[i]))
|
2020-10-02 12:23:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|