From 90edc69c372c0d520e59f81c499e984b149c8708 Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Tue, 12 Dec 2017 14:05:23 +1030 Subject: [PATCH] Commit ignored upstream compatibility symbols This file currently has an ignore build tag, and won't be built until it can be determined which of the upstream exported symbols are actually in use. --- gzip_compat.go | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 gzip_compat.go diff --git a/gzip_compat.go b/gzip_compat.go new file mode 100644 index 0000000..a2834be --- /dev/null +++ b/gzip_compat.go @@ -0,0 +1,93 @@ +// +build go1.9 +// +build ignore + +package gziphandler + +import "net/http" + +const ( + // DefaultQValue is the default qvalue to assign to an encoding if no explicit qvalue is set. + // This is actually kind of ambiguous in RFC 2616, so hopefully it's correct. + // The examples seem to indicate that it is. + // + // Deprecated: maintained for compatibility, no longer used. + DefaultQValue = 1.0 + + // DefaultMinSize defines the minimum size to reach to enable compression. + // It's 512 bytes. + // + // Deprecated: maintained for compatibility. + DefaultMinSize = defaultMinSize +) + +// DeprecatedHandler is a type alias to to group deprecated +// functions together for godoc. +// +// This will be removed once godoc automatically groups +// deprecated symbols, see golang/go#17056. +type DeprecatedHandler = http.Handler + +// DeprecatedMiddleware is a type alias to to group +// deprecated functions together for godoc. +// +// This will be removed once godoc automatically groups +// deprecated symbols, see golang/go#17056. +type DeprecatedMiddleware = func(http.Handler) http.Handler + +// GzipHandler wraps an HTTP handler, to transparently gzip +// the response body if the client supports it (via the +// Accept-Encoding header). This will compress at the +// default compression level. +// +// Deprecated: maintained for compatibility, use Gzip. +func GzipHandler(h http.Handler) DeprecatedHandler { + return Gzip(h) +} + +// GzipHandlerWithOpts ... +// +// Deprecated: maintained for compatibility, use Wrapper. +func GzipHandlerWithOpts(opts ...option) (DeprecatedMiddleware, error) { + return Wrapper(opts), nil +} + +// MustNewGzipLevelHandler behaves just like +// NewGzipLevelHandler except that in an error case it +// panics rather than returning an error. +// +// Deprecated: maintained for compatibility, use Wrapper. +func MustNewGzipLevelHandler(level int) DeprecatedMiddleware { + return Wrapper(CompressionLevel(level)) +} + +// NewGzipLevelAndMinSize behave as NewGzipLevelHandler +// except it let the caller specify the minimum size before +// compression. +// +// Deprecated: maintained for compatibility, use Wrapper. +func NewGzipLevelAndMinSize(level, minSize int) (DeprecatedMiddleware, error) { + return Wrapper(CompressionLevel(level), MinSize(minSize)), nil +} + +// NewGzipLevelHandler returns a wrapper function (often +// known as middleware) which can be used to wrap an HTTP +// handler to transparently gzip the response body if the +// client supports it (via the Accept-Encoding header). +// Responses will be encoded at the given gzip compression +// level. An error will be returned only if an invalid gzip +// compression level is given, so if one can ensure the +// level is valid, the returned error can be safely ignored. +// +// Deprecated: maintained for compatibility, use Wrapper. +func NewGzipLevelHandler(level int) (DeprecatedMiddleware, error) { + return Wrapper(CompressionLevel(level)), nil +} + +/*type GzipResponseWriter + func (w *GzipResponseWriter) Close() error + func (w *GzipResponseWriter) Flush() + func (w *GzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) + func (w *GzipResponseWriter) Push(target string, opts *http.PushOptions) error + func (w *GzipResponseWriter) Write(b []byte) (int, error) + func (w *GzipResponseWriter) WriteHeader(code int) +*/