Fixes after review

After discussion, we decided to simplify attribute translation for now. Full translation requires support for UTF-8 values encoded according to RFC 8187/7230, this can be clarified and implemented in further PRs.

1. Remove translation tables
2. Use simple translation rules only, for now ignoring UTF-8 keys and values

- `X-Attribute-NEOFS-` prefixed headers considered well-known system attributes
- System Attribute key is uppercased
- System Attribute key's `-` translates to `_`
- `X-Attribute-` prefixed headers considered regular object attributes
- Normal attribute key is a result of http header prefix trimming
- Value string should be left as is, for now

```
HTTP:
X-Attribute-NEOFS-Expiration-Epoch: 123
X-Attribute-FileName: cat.jpg

NeoFS:
__NEOFS__EXPIRATION_EPOCH: "123"
FileName: "cat.jpg"
```

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2021-02-03 16:01:30 +03:00
parent 71999a796d
commit cbaf9e6142
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
5 changed files with 30 additions and 83 deletions

View file

@ -54,9 +54,6 @@ const (
cfgLoggerSamplingThereafter = "logger.sampling.thereafter"
// Uploader Header
cfgUploaderHeader = "uploader_header"
cfgUploaderHeaderKey = "key"
cfgUploaderHeaderVal = "val"
cfgUploaderHeaderEnableDefaultTimestamp = "upload_header.use_default_timestamp"
// Peers
@ -187,13 +184,6 @@ func settings() *viper.Viper {
fmt.Printf("%s_%s_[N]_ADDRESS = string\n", Prefix, strings.ToUpper(cfgPeers))
fmt.Printf("%s_%s_[N]_WEIGHT = 0..1 (float)\n", Prefix, strings.ToUpper(cfgPeers))
fmt.Println()
fmt.Println("Upload Header Table:")
fmt.Println()
fmt.Printf("%s_%s_[N]_%s = string\n", Prefix, strings.ToUpper(cfgUploaderHeader), strings.ToUpper(cfgUploaderHeaderKey))
fmt.Printf("%s_%s_[N]_%s = string\n", Prefix, strings.ToUpper(cfgUploaderHeader), strings.ToUpper(cfgUploaderHeaderVal))
os.Exit(0)
case version != nil && *version:
fmt.Printf("NeoFS HTTP Gateway %s (%s)\n", Version, Build)