selectEncoder returns the name of the encoder
(h http.Header)
| 344 | |
| 345 | // selectEncoder returns the name of the encoder |
| 346 | func (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. |
| 364 | func (c *Compressor) getEncoder(name string, w io.Writer) (io.WriteCloser, func()) { |
no test coverage detected