@@ -12,13 +12,15 @@ import (
1212)
1313
1414var  (
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. 
1818	DefaultExcludedExtentions  =  NewExcludedExtensions ([]string {
1919		".png" , ".gif" , ".jpeg" , ".jpg" ,
2020	})
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" )
2224)
2325
2426// Option is an interface that defines a method to apply a configuration 
@@ -241,11 +243,12 @@ func DefaultDecompressHandle(c *gin.Context) {
241243		}
242244
243245		if  trimmedValue  !=  "gzip"  {
246+ 			// According to RFC 7231, Section 3.1.2.2: 
244247			// https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.2 
245248			// An origin server MAY respond with a status code of 415 (Unsupported 
246249			// Media Type) if a representation in the request message has a content 
247250			// coding that is not acceptable. 
248- 			_  =  c .AbortWithError (http .StatusUnsupportedMediaType , UnsupportedContentEncoding )
251+ 			_  =  c .AbortWithError (http .StatusUnsupportedMediaType , ErrUnsupportedContentEncoding )
249252		}
250253
251254		r , err  :=  gzip .NewReader (c .Request .Body )
0 commit comments