From 3621179560bab27ab63f232663d87bf60370110b Mon Sep 17 00:00:00 2001 From: Jim Kalafut Date: Wed, 18 Sep 2019 14:24:41 -0700 Subject: [PATCH] Fix Agent handling of gzipped responses (#7470) * Fix Agent handling of gzipped responses Fixes #6606 * Only remove "gzip" member, if present * Simplify to just removing Accept-Encoding altogether --- command/agent/cache/api_proxy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command/agent/cache/api_proxy.go b/command/agent/cache/api_proxy.go index f0a919121..580c14f75 100644 --- a/command/agent/cache/api_proxy.go +++ b/command/agent/cache/api_proxy.go @@ -36,6 +36,11 @@ func (ap *APIProxy) Send(ctx context.Context, req *SendRequest) (*SendResponse, return nil, err } client.SetToken(req.Token) + + // http.Transport will transparently request gzip and decompress the response, but only if + // the client doesn't manually set the header. Removing any Accept-Encoding header allows the + // transparent compression to occur. + req.Request.Header.Del("Accept-Encoding") client.SetHeaders(req.Request.Header) fwReq := client.NewRequest(req.Request.Method, req.Request.URL.Path)