MCPcopy Create free account
hub / github.com/kataras/iris / ClientSupportsEncoding

Method ClientSupportsEncoding

context/context.go:3562–3578  ·  view source on GitHub ↗

+------------------------------------------------------------+ | Body Writers with compression | +------------------------------------------------------------+ ClientSupportsEncoding reports whether the client expects one of the given "encodings" compression. Note, this

(encodings ...string)

Source from the content-addressed store, hash-verified

3560// meaning that request accept-encoding offers don't matter here.
3561// See `CompressWriter` too.
3562func (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

Callers

nothing calls this directly

Calls 2

GetHeaderMethod · 0.95
ContainsMethod · 0.80

Tested by

no test coverage detected