forked from nytimes/gziphandler
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhandle.go
More file actions
27 lines (22 loc) · 683 Bytes
/
handle.go
File metadata and controls
27 lines (22 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package httpcompression
import "mime"
// returns true if we've been configured to compress the specific content type.
func handleContentType(ct string, contentTypes []parsedContentType, blacklist bool) bool {
// If contentTypes is empty we handle all content types.
if len(contentTypes) == 0 {
return !blacklist
}
return handleContentTypeSlow(ct, contentTypes, blacklist)
}
func handleContentTypeSlow(ct string, contentTypes []parsedContentType, blacklist bool) bool {
mediaType, params, err := mime.ParseMediaType(ct)
if err != nil {
return false
}
for _, c := range contentTypes {
if c.equals(mediaType, params) {
return !blacklist
}
}
return blacklist
}