From 5efb80e10fa6d7b2ba48c8d749e1ebda767acae1 Mon Sep 17 00:00:00 2001 From: Adrian-Stefan Mares Date: Tue, 12 Dec 2023 14:38:01 +0100 Subject: [PATCH] all: Remove HTTP compression experimental flags --- CHANGELOG.md | 2 ++ pkg/httpclient/http.go | 7 +------ pkg/web/web.go | 18 ++---------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15ed3760f0..a633d69edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ For details about compatibility between different releases, see the **Commitment ### Removed +- The `http.client.transport.compression` and `http.server.transport.compression` experimental flags. + ### Fixed ### Security diff --git a/pkg/httpclient/http.go b/pkg/httpclient/http.go index 0e6fe3b7bf..f6d9266b62 100644 --- a/pkg/httpclient/http.go +++ b/pkg/httpclient/http.go @@ -26,13 +26,10 @@ import ( "github.com/klauspost/compress/gzhttp" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.thethings.network/lorawan-stack/v3/pkg/config/tlsconfig" - "go.thethings.network/lorawan-stack/v3/pkg/experimental" "go.thethings.network/lorawan-stack/v3/pkg/telemetry/tracing" "go.thethings.network/lorawan-stack/v3/pkg/version" ) -var transportCompressionFeatureFlag = experimental.DefineFeature("http.client.transport.compression", true) - // defaultHTTPClientTimeout is the default timeout for the HTTP client. const defaultHTTPClientTimeout = 10 * time.Second @@ -100,9 +97,7 @@ func (p *provider) HTTPClient(ctx context.Context, opts ...Option) (*http.Client transport.TLSClientConfig = options.tlsConfig var rt http.RoundTripper = transport - if transportCompressionFeatureFlag.GetValue(ctx) { - rt = gzhttp.Transport(rt) - } + rt = gzhttp.Transport(rt) rt = otelhttp.NewTransport( rt, otelhttp.WithTracerProvider(tracing.FromContext(ctx)), diff --git a/pkg/web/web.go b/pkg/web/web.go index a5c1f0c270..1d32d9c675 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -30,7 +30,6 @@ import ( "github.com/klauspost/compress/gzhttp" "go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux" "go.thethings.network/lorawan-stack/v3/pkg/errors" - "go.thethings.network/lorawan-stack/v3/pkg/experimental" "go.thethings.network/lorawan-stack/v3/pkg/fillcontext" "go.thethings.network/lorawan-stack/v3/pkg/log" "go.thethings.network/lorawan-stack/v3/pkg/random" @@ -41,19 +40,6 @@ import ( "gopkg.in/yaml.v2" ) -var responseCompressionFeatureFlag = experimental.DefineFeature("http.server.transport.compression", true) - -func compressionMiddleware(ctx context.Context) (func(http.Handler) http.Handler, error) { - if !responseCompressionFeatureFlag.GetValue(ctx) { - return func(next http.Handler) http.Handler { return next }, nil - } - m, err := gzhttp.NewWrapper() - if err != nil { - return nil, err - } - return func(h http.Handler) http.Handler { return m(h) }, nil -} - // Registerer allows components to register their services to the web server. type Registerer interface { RegisterRoutes(s *Server) @@ -189,7 +175,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) { if err := proxyConfiguration.ParseAndAddTrusted(options.trustedProxies...); err != nil { return nil, err } - compressor, err := compressionMiddleware(ctx) + compressor, err := gzhttp.NewWrapper() if err != nil { return nil, err } @@ -200,7 +186,7 @@ func New(ctx context.Context, opts ...Option) (*Server, error) { "text/html": webhandlers.Template, }), mux.MiddlewareFunc(webmiddleware.Recover()), - compressor, + func(next http.Handler) http.Handler { return compressor(next) }, otelmux.Middleware("ttn-lw-stack", otelmux.WithTracerProvider(tracing.FromContext(ctx))), mux.MiddlewareFunc(webmiddleware.FillContext(options.contextFillers...)), mux.MiddlewareFunc(webmiddleware.Peer()),