MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / newCacheKey

Function newCacheKey

proxy.go:542–567  ·  view source on GitHub ↗
(s *scope, origParams url.Values, q []byte, req *http.Request)

Source from the content-addressed store, hash-verified

540}
541
542func newCacheKey(s *scope, origParams url.Values, q []byte, req *http.Request) *cache.Key {
543 var userParamsHash uint32
544 if s.user.params != nil {
545 userParamsHash = s.user.params.key
546 }
547
548 queryParamsHash := calcQueryParamsHash(origParams)
549 credHash, err := uint32(0), error(nil)
550
551 if !s.user.cache.SharedWithAllUsers {
552 credHash, err = calcCredentialHash(s.clusterUser.name, s.clusterUser.password)
553 }
554 if err != nil {
555 log.Errorf("fail to calc hash on credentials for user %s", s.user.name)
556 credHash = 0
557 }
558
559 return cache.NewKey(
560 skipLeadingComments(q),
561 origParams,
562 sortHeader(req.Header.Get("Accept-Encoding")),
563 userParamsHash,
564 queryParamsHash,
565 credHash,
566 )
567}
568
569func toString(stream io.Reader) (string, error) {
570 buf := new(bytes.Buffer)

Callers 1

serveFromCacheMethod · 0.85

Calls 7

ErrorfFunction · 0.92
NewKeyFunction · 0.92
calcQueryParamsHashFunction · 0.85
calcCredentialHashFunction · 0.85
skipLeadingCommentsFunction · 0.85
sortHeaderFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected