MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / NewDetector

Function NewDetector

clientfeatures/detector.go:21–41  ·  view source on GitHub ↗

NewDetector creates a new Detector instance

(config *Config)

Source from the content-addressed store, hash-verified

19
20// NewDetector creates a new Detector instance
21func NewDetector(config *Config) *Detector {
22 vary := make([]string, 0, 5)
23
24 if config.AutoWebp || config.EnforceWebp ||
25 config.AutoAvif || config.EnforceAvif ||
26 config.AutoJxl || config.EnforceJxl {
27 vary = append(vary, httpheaders.Accept)
28 }
29
30 if config.EnableClientHints {
31 vary = append(
32 vary,
33 httpheaders.SecChDpr, httpheaders.Dpr, httpheaders.SecChWidth, httpheaders.Width,
34 )
35 }
36
37 return &Detector{
38 config: config,
39 vary: strings.Join(vary, ", "),
40 }
41}
42
43// Features detects client features from HTTP headers
44func (d *Detector) Features(header http.Header) Features {

Callers 3

NewFunction · 0.92
runTestCasesMethod · 0.92
TestSetVaryMethod · 0.92

Calls

no outgoing calls

Tested by 2

runTestCasesMethod · 0.74
TestSetVaryMethod · 0.74