Skip to content

Commit

Permalink
fix: FromHTTPHeader add stale
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Jul 26, 2024
1 parent dd76b7e commit 3423027
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cloud/metainfo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ func FromHTTPHeader(ctx context.Context, h HTTPHeaderCarrier) context.Context {
// inherit from exist ctx node
persistent := newKVStore()
transient := newKVStore()
stale := newKVStore()
sliceToMap(nd.persistent, persistent)
sliceToMap(nd.transient, transient)
sliceToMap(nd.stale, stale)

// insert new kvs from http header
h.Visit(func(k, v string) {
Expand All @@ -104,14 +106,15 @@ func FromHTTPHeader(ctx context.Context, h HTTPHeaderCarrier) context.Context {
})

// return original ctx if no invalid key in http header
if (persistent.size() + transient.size()) == 0 {
if (persistent.size() + transient.size() + stale.size()) == 0 {
return ctx
}

// make new kvs
nd = newNodeFromMaps(persistent, transient, nil)
nd = newNodeFromMaps(persistent, transient, stale)
persistent.recycle()
transient.recycle()
stale.recycle()
ctx = withNode(ctx, nd)
return ctx
}
Expand Down

0 comments on commit 3423027

Please sign in to comment.