feat: publish v1.0.0-rc.36-custom.1
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
This commit is contained in:
commit
bb7968b612
2381 files changed
+551494
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type digestAnchor struct{}
|
||||
|
||||
func modulePath() string {
|
||||
return reflect.TypeFor[digestAnchor]().PkgPath()
|
||||
}
|
||||
|
||||
var digestSeed = func() (s [sha256.Size]byte) {
|
||||
return sha256.Sum256([]byte(modulePath()))
|
||||
}()
|
||||
|
||||
// ETagFor returns a weak ETag derived from the namespace and content.
|
||||
func ETagFor(namespace, content string) string {
|
||||
buf := make([]byte, 0, sha256.Size+1+len(namespace)+1+len(content))
|
||||
buf = append(buf, digestSeed[:]...)
|
||||
buf = append(buf, 0)
|
||||
buf = append(buf, namespace...)
|
||||
buf = append(buf, 0)
|
||||
buf = append(buf, content...)
|
||||
digest := sha256.Sum256(buf)
|
||||
return `W/"` + hex.EncodeToString(digest[:]) + `"`
|
||||
}
|
||||
|
||||
// ETagMatches reports whether an If-None-Match header matches etag under weak
|
||||
// comparison (RFC 9110 §13.1.2): the W/ prefix is ignored on both sides, and
|
||||
// "*" matches everything.
|
||||
func ETagMatches(ifNoneMatch, etag string) bool {
|
||||
ifNoneMatch = strings.TrimSpace(ifNoneMatch)
|
||||
if ifNoneMatch == "" {
|
||||
return false
|
||||
}
|
||||
if ifNoneMatch == "*" {
|
||||
return true
|
||||
}
|
||||
etag = strings.TrimPrefix(etag, "W/")
|
||||
for candidate := range strings.SplitSeq(ifNoneMatch, ",") {
|
||||
if strings.TrimPrefix(strings.TrimSpace(candidate), "W/") == etag {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in new issue
Block a user