Skip to content

Commit

Permalink
Adding new compressible prefixes (#1092)
Browse files Browse the repository at this point in the history
* Adding "image/svg" as compressible prefix

* Adding additional compressible prefixes from https://support.cloudflare.com/hc/en-us/articles/200168396-What-will-Cloudflare-compress-
  • Loading branch information
kyleu committed Sep 7, 2021
1 parent 1647255 commit 713da4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion header.go
Expand Up @@ -271,7 +271,11 @@ func (h *RequestHeader) SetContentLength(contentLength int) {
func (h *ResponseHeader) isCompressibleContentType() bool {
contentType := h.ContentType()
return bytes.HasPrefix(contentType, strTextSlash) ||
bytes.HasPrefix(contentType, strApplicationSlash)
bytes.HasPrefix(contentType, strApplicationSlash) ||
bytes.HasPrefix(contentType, strImageSVG) ||
bytes.HasPrefix(contentType, strImageIcon) ||
bytes.HasPrefix(contentType, strFontSlash) ||
bytes.HasPrefix(contentType, strMultipartSlash)
}

// ContentType returns Content-Type header value.
Expand Down
9 changes: 7 additions & 2 deletions strings.go
Expand Up @@ -71,7 +71,12 @@ var (
strMultipartFormData = []byte("multipart/form-data")
strBoundary = []byte("boundary")
strBytes = []byte("bytes")
strTextSlash = []byte("text/")
strApplicationSlash = []byte("application/")
strBasicSpace = []byte("Basic ")

strApplicationSlash = []byte("application/")
strImageSVG = []byte("image/svg")
strImageIcon = []byte("image/x-icon")
strFontSlash = []byte("font/")
strMultipartSlash = []byte("multipart/")
strTextSlash = []byte("text/")
)

0 comments on commit 713da4e

Please sign in to comment.