mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Vendor Update Go Libs (#13166)
* update github.com/alecthomas/chroma v0.8.0 -> v0.8.1 * github.com/blevesearch/bleve v1.0.10 -> v1.0.12 * editorconfig-core-go v2.1.1 -> v2.3.7 * github.com/gliderlabs/ssh v0.2.2 -> v0.3.1 * migrate editorconfig.ParseBytes to Parse * github.com/shurcooL/vfsgen to 0d455de96546 * github.com/go-git/go-git/v5 v5.1.0 -> v5.2.0 * github.com/google/uuid v1.1.1 -> v1.1.2 * github.com/huandu/xstrings v1.3.0 -> v1.3.2 * github.com/klauspost/compress v1.10.11 -> v1.11.1 * github.com/markbates/goth v1.61.2 -> v1.65.0 * github.com/mattn/go-sqlite3 v1.14.0 -> v1.14.4 * github.com/mholt/archiver v3.3.0 -> v3.3.2 * github.com/microcosm-cc/bluemonday 4f7140c49acb -> v1.0.4 * github.com/minio/minio-go v7.0.4 -> v7.0.5 * github.com/olivere/elastic v7.0.9 -> v7.0.20 * github.com/urfave/cli v1.20.0 -> v1.22.4 * github.com/prometheus/client_golang v1.1.0 -> v1.8.0 * github.com/xanzy/go-gitlab v0.37.0 -> v0.38.1 * mvdan.cc/xurls v2.1.0 -> v2.2.0 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		
							
								
								
									
										57
									
								
								vendor/github.com/andybalholm/brotli/writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										57
									
								
								vendor/github.com/andybalholm/brotli/writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,12 +1,8 @@
 | 
			
		||||
package brotli
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"compress/gzip"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/gddo/httputil"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -50,11 +46,8 @@ func NewWriterLevel(dst io.Writer, level int) *Writer {
 | 
			
		||||
// NewWriterOptions is like NewWriter but specifies WriterOptions
 | 
			
		||||
func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer {
 | 
			
		||||
	w := new(Writer)
 | 
			
		||||
	w.options = options
 | 
			
		||||
	w.Reset(dst)
 | 
			
		||||
	w.params.quality = options.Quality
 | 
			
		||||
	if options.LGWin > 0 {
 | 
			
		||||
		w.params.lgwin = uint(options.LGWin)
 | 
			
		||||
	}
 | 
			
		||||
	return w
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -63,6 +56,10 @@ func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer {
 | 
			
		||||
// instead. This permits reusing a Writer rather than allocating a new one.
 | 
			
		||||
func (w *Writer) Reset(dst io.Writer) {
 | 
			
		||||
	encoderInitState(w)
 | 
			
		||||
	w.params.quality = w.options.Quality
 | 
			
		||||
	if w.options.LGWin > 0 {
 | 
			
		||||
		w.params.lgwin = uint(w.options.LGWin)
 | 
			
		||||
	}
 | 
			
		||||
	w.dst = dst
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -70,6 +67,9 @@ func (w *Writer) writeChunk(p []byte, op int) (n int, err error) {
 | 
			
		||||
	if w.dst == nil {
 | 
			
		||||
		return 0, errWriterClosed
 | 
			
		||||
	}
 | 
			
		||||
	if w.err != nil {
 | 
			
		||||
		return 0, w.err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for {
 | 
			
		||||
		availableIn := uint(len(p))
 | 
			
		||||
@@ -82,16 +82,8 @@ func (w *Writer) writeChunk(p []byte, op int) (n int, err error) {
 | 
			
		||||
			return n, errEncode
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		outputData := encoderTakeOutput(w)
 | 
			
		||||
 | 
			
		||||
		if len(outputData) > 0 {
 | 
			
		||||
			_, err = w.dst.Write(outputData)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return n, err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if len(p) == 0 {
 | 
			
		||||
			return n, nil
 | 
			
		||||
		if len(p) == 0 || w.err != nil {
 | 
			
		||||
			return n, w.err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -124,32 +116,3 @@ type nopCloser struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nopCloser) Close() error { return nil }
 | 
			
		||||
 | 
			
		||||
// HTTPCompressor chooses a compression method (brotli, gzip, or none) based on
 | 
			
		||||
// the Accept-Encoding header, sets the Content-Encoding header, and returns a
 | 
			
		||||
// WriteCloser that implements that compression. The Close method must be called
 | 
			
		||||
// before the current HTTP handler returns.
 | 
			
		||||
//
 | 
			
		||||
// Due to https://github.com/golang/go/issues/31753, the response will not be
 | 
			
		||||
// compressed unless you set a Content-Type header before you call
 | 
			
		||||
// HTTPCompressor.
 | 
			
		||||
func HTTPCompressor(w http.ResponseWriter, r *http.Request) io.WriteCloser {
 | 
			
		||||
	if w.Header().Get("Content-Type") == "" {
 | 
			
		||||
		return nopCloser{w}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if w.Header().Get("Vary") == "" {
 | 
			
		||||
		w.Header().Set("Vary", "Accept-Encoding")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	encoding := httputil.NegotiateContentEncoding(r, []string{"br", "gzip"})
 | 
			
		||||
	switch encoding {
 | 
			
		||||
	case "br":
 | 
			
		||||
		w.Header().Set("Content-Encoding", "br")
 | 
			
		||||
		return NewWriter(w)
 | 
			
		||||
	case "gzip":
 | 
			
		||||
		w.Header().Set("Content-Encoding", "gzip")
 | 
			
		||||
		return gzip.NewWriter(w)
 | 
			
		||||
	}
 | 
			
		||||
	return nopCloser{w}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user