MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / processContentEncoding

Function processContentEncoding

rest/multipart.go:71–88  ·  view source on GitHub ↗

processContentEncoding performs the Content-Type validation and Content-Encoding check.

(headers http.Header, input io.ReadCloser, expectedContentTypeMime string)

Source from the content-addressed store, hash-verified

69
70// processContentEncoding performs the Content-Type validation and Content-Encoding check.
71func processContentEncoding(headers http.Header, input io.ReadCloser, expectedContentTypeMime string) (io.ReadCloser, error) {
72 contentType := headers.Get("Content-Type")
73 if contentType != "" && !strings.HasPrefix(contentType, expectedContentTypeMime) {
74 return input, base.HTTPErrorf(http.StatusUnsupportedMediaType, "Invalid content type %s - expected %s", contentType, expectedContentTypeMime)
75 }
76 switch headers.Get("Content-Encoding") {
77 case "gzip":
78 var err error
79 if input, err = gzip.NewReader(input); err != nil {
80 return input, err
81 }
82 case "":
83 break
84 default:
85 return input, base.HTTPErrorf(http.StatusUnsupportedMediaType, "Unsupported Content-Encoding; use gzip")
86 }
87 return input, nil
88}
89
90type attInfo struct {
91 name string

Callers 4

ReadJSONFromMIMERawErrFunction · 0.85
readSanitizeJSONMethod · 0.85
readJavascriptMethod · 0.85
getFunctionArgsMethod · 0.85

Calls 2

HTTPErrorfFunction · 0.92
GetMethod · 0.45

Tested by

no test coverage detected