Skip to content

Commit

Permalink
ver 3.23; canonical header
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed May 27, 2024
1 parent fac4625 commit 6c23a66
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ linters:
- revive
- asciicheck
- bodyclose
- canonicalheader
- dogsled
- dupl
- durationcheck
- errcheck
- exportloopref
- fatcontext
- gci
- gocritic
- gofmt
Expand Down
25 changes: 17 additions & 8 deletions api/apc/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package apc
import (
"fmt"
"net/http"
"net/textproto"
"strconv"

"github.com/NVIDIA/aistore/cmn/cos"
Expand All @@ -21,24 +22,32 @@ type BlobMsg struct {
LatestVer bool `json:"latest-ver"`
}

// using textproto.CanonicalMIMEHeaderKey() to check presence -
// if a given key is present and is an empty string, it's an error
func (msg *BlobMsg) FromHeader(hdr http.Header) error {
snw, schunk := hdr.Get(HdrBlobWorkers), hdr.Get(HdrBlobChunk)
if snw != "" {
nw, err := strconv.ParseInt(snw, 10, 16)
canWorkers := textproto.CanonicalMIMEHeaderKey(HdrBlobWorkers)
valWorkers, okw := hdr[canWorkers]
if okw {
// single value
nw, err := strconv.ParseInt(valWorkers[0], 10, 16)
if err != nil {
return fmt.Errorf("%s: failed to parse %s=%s: %v", _bldl, HdrBlobWorkers, snw, err)
return fmt.Errorf("%s: failed to parse %s=%s: %v", _bldl, HdrBlobWorkers, valWorkers[0], err)
}
if nw < 0 || nw > 128 {
return fmt.Errorf("%s: invalid %s=%s: expecting (0..128) range", _bldl, HdrBlobWorkers, snw)
return fmt.Errorf("%s: invalid %s=%s: expecting (0..128) range", _bldl, HdrBlobWorkers, valWorkers[0])
}
msg.NumWorkers = int(nw)
}
if schunk == "" {

canChunkSz := textproto.CanonicalMIMEHeaderKey(HdrBlobChunk)
valChunkSz, okz := hdr[canChunkSz]
if !okz {
return nil
}
chunk, err := cos.ParseSize(schunk, "")
// single value
chunk, err := cos.ParseSize(valChunkSz[0], "")
if err != nil {
return fmt.Errorf("%s: failed to parse %s=%s: %v", _bldl, HdrBlobChunk, schunk, err)
return fmt.Errorf("%s: failed to parse %s=%s: %v", _bldl, HdrBlobChunk, valChunkSz[0], err)
}
msg.ChunkSize = chunk
return nil
Expand Down
7 changes: 4 additions & 3 deletions api/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,13 @@ func HeadObject(bp BaseParams, bck cmn.Bck, objName string, fltPresence int, sil
// second, all the rest
err = cmn.IterFields(op, func(tag string, field cmn.IterField) (error, bool) {
headerName := apc.PropToHeader(tag)
// skip the missing ones
if _, ok := hdr[textproto.CanonicalMIMEHeaderKey(headerName)]; !ok {
// get values, skip the missing ones
v, ok := hdr[textproto.CanonicalMIMEHeaderKey(headerName)]
if !ok {
return nil, false
}
// single-value
return field.SetValue(hdr.Get(headerName), true /*force*/), false
return field.SetValue(v[0], true /*force*/), false
}, cmn.IterOpts{OnlyRead: false})
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions cmn/ver_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const GitHubHome = "https://github.com/NVIDIA/aistore"
// `jsp` formats its *signature* and other implementation details.

const (
VersionAIStore = "3.23.rc4"
VersionAIStore = "3.23"
VersionCLI = "1.12"
VersionLoader = "1.10"
VersionLoader = "1.11"
VersionAuthN = "1.0"
)

Expand Down

0 comments on commit 6c23a66

Please sign in to comment.