MCPcopy Index your code
hub / github.com/coder/coder / selectEncoder

Method selectEncoder

coderd/cachecompress/compress.go:346–361  ·  view source on GitHub ↗

selectEncoder returns the name of the encoder

(h http.Header)

Source from the content-addressed store, hash-verified

344
345// selectEncoder returns the name of the encoder
346func (c *Compressor) selectEncoder(h http.Header) string {
347 header := h.Get("Accept-Encoding")
348
349 // Parse the names of all accepted algorithms from the header.
350 accepted := strings.Split(strings.ToLower(header), ",")
351
352 // Find supported encoder by accepted list by precedence
353 for _, name := range c.encodingPrecedence {
354 if matchAcceptEncoding(accepted, name) {
355 return name
356 }
357 }
358
359 // No encoder found to match the accepted encoding
360 return ""
361}
362
363// getEncoder returns a writer that encodes and writes to the provided writer, and a cleanup func.
364func (c *Compressor) getEncoder(name string, w io.Writer) (io.WriteCloser, func()) {

Callers 1

ServeHTTPMethod · 0.95

Calls 2

matchAcceptEncodingFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected