+------------------------------------------------------------+ | Body Writers with compression | +------------------------------------------------------------+ ClientSupportsEncoding reports whether the client expects one of the given "encodings" compression. Note, this
(encodings ...string)
| 3560 | // meaning that request accept-encoding offers don't matter here. |
| 3561 | // See `CompressWriter` too. |
| 3562 | func (ctx *Context) ClientSupportsEncoding(encodings ...string) bool { |
| 3563 | if len(encodings) == 0 { |
| 3564 | return false |
| 3565 | } |
| 3566 | |
| 3567 | if h := ctx.GetHeader(AcceptEncodingHeaderKey); h != "" { |
| 3568 | for _, v := range strings.Split(h, ",") { |
| 3569 | for _, encoding := range encodings { |
| 3570 | if strings.Contains(v, encoding) { |
| 3571 | return true |
| 3572 | } |
| 3573 | } |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | return false |
| 3578 | } |
| 3579 | |
| 3580 | // CompressWriter enables or disables the compress response writer. |
| 3581 | // if the client expects a valid compression algorithm then this |