@@ -12,13 +12,15 @@ import (
12
12
)
13
13
14
14
var (
15
- // DefaultExcludedExtentions is a predefined list of file extensions that should be excluded from gzip compression.
16
- // These extensions typically represent image files that are already compressed
17
- // and do not benefit from additional compression.
15
+ // DefaultExcludedExtentions is a predefined list of file extensions that should be excluded from gzip compression.
16
+ // These extensions typically represent image files that are already compressed
17
+ // and do not benefit from additional compression.
18
18
DefaultExcludedExtentions = NewExcludedExtensions ([]string {
19
19
".png" , ".gif" , ".jpeg" , ".jpg" ,
20
20
})
21
- UnsupportedContentEncoding = errors .New ("Unsupported content encoding" )
21
+ // ErrUnsupportedContentEncoding is an error that indicates the content encoding
22
+ // is not supported by the application.
23
+ ErrUnsupportedContentEncoding = errors .New ("unsupported content encoding" )
22
24
)
23
25
24
26
// Option is an interface that defines a method to apply a configuration
@@ -241,11 +243,12 @@ func DefaultDecompressHandle(c *gin.Context) {
241
243
}
242
244
243
245
if trimmedValue != "gzip" {
246
+ // According to RFC 7231, Section 3.1.2.2:
244
247
// https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.2
245
248
// An origin server MAY respond with a status code of 415 (Unsupported
246
249
// Media Type) if a representation in the request message has a content
247
250
// coding that is not acceptable.
248
- _ = c .AbortWithError (http .StatusUnsupportedMediaType , UnsupportedContentEncoding )
251
+ _ = c .AbortWithError (http .StatusUnsupportedMediaType , ErrUnsupportedContentEncoding )
249
252
}
250
253
251
254
r , err := gzip .NewReader (c .Request .Body )
0 commit comments