gin-contrib / gzip

Gin middleware to enable GZIP support.
MIT License
330 stars 87 forks source link

Does this middleware (DefaultDecompressHandle) handle gzip.Close() correctly? #43

Open arianitu opened 3 years ago

arianitu commented 3 years ago

I'm looking at the code here:

func DefaultDecompressHandle(c *gin.Context) {
    if c.Request.Body == nil {
        return
    }
    r, err := gzip.NewReader(c.Request.Body)
    if err != nil {
        c.AbortWithError(http.StatusBadRequest, err)
        return
    }
    c.Request.Header.Del("Content-Encoding")
    c.Request.Header.Del("Content-Length")
    c.Request.Body = r
}

I don't see a close on the gzip.NewReader which the documentation says should be called. Is this handling close correctly?