mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore]: Bump github.com/gin-contrib/gzip from 1.1.0 to 1.2.2 (#3693)
Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.1.0 to 1.2.2. - [Release notes](https://github.com/gin-contrib/gzip/releases) - [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml) - [Commits](https://github.com/gin-contrib/gzip/compare/v1.1.0...v1.2.2) --- updated-dependencies: - dependency-name: github.com/gin-contrib/gzip dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
28
vendor/github.com/gin-contrib/gzip/gzip.go
generated
vendored
28
vendor/github.com/gin-contrib/gzip/gzip.go
generated
vendored
@ -1,7 +1,11 @@
|
||||
package gzip
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"compress/gzip"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -11,6 +15,7 @@ const (
|
||||
BestSpeed = gzip.BestSpeed
|
||||
DefaultCompression = gzip.DefaultCompression
|
||||
NoCompression = gzip.NoCompression
|
||||
HuffmanOnly = gzip.HuffmanOnly
|
||||
)
|
||||
|
||||
func Gzip(level int, options ...Option) gin.HandlerFunc {
|
||||
@ -32,8 +37,31 @@ func (g *gzipWriter) Write(data []byte) (int, error) {
|
||||
return g.writer.Write(data)
|
||||
}
|
||||
|
||||
func (g *gzipWriter) Flush() {
|
||||
_ = g.writer.Flush()
|
||||
g.ResponseWriter.Flush()
|
||||
}
|
||||
|
||||
// Fix: https://github.com/mholt/caddy/issues/38
|
||||
func (g *gzipWriter) WriteHeader(code int) {
|
||||
g.Header().Del("Content-Length")
|
||||
g.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
// Ensure gzipWriter implements the http.Hijacker interface.
|
||||
// This will cause a compile-time error if gzipWriter does not implement all methods of the http.Hijacker interface.
|
||||
var _ http.Hijacker = (*gzipWriter)(nil)
|
||||
|
||||
// Hijack allows the caller to take over the connection from the HTTP server.
|
||||
// After a call to Hijack, the HTTP server library will not do anything else with the connection.
|
||||
// It becomes the caller's responsibility to manage and close the connection.
|
||||
//
|
||||
// It returns the underlying net.Conn, a buffered reader/writer for the connection, and an error
|
||||
// if the ResponseWriter does not support the Hijacker interface.
|
||||
func (g *gzipWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
hijacker, ok := g.ResponseWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("the ResponseWriter doesn't support the Hijacker interface")
|
||||
}
|
||||
return hijacker.Hijack()
|
||||
}
|
||||
|
Reference in New Issue
Block a user