Skip to content

Commit

Permalink
client: Disable compression in default transport
Browse files Browse the repository at this point in the history
The default Golang client will advertise to the HTTP server that
it can handle gzip compressed response encoding. This is true,
but it breaks our artifacts.go code for doing download progress.

This is because the default behavior of the transport is to:

 * provide the proper reader to decompress the response
 * update the content-length header to be -1

The -1 breaks our logic. This fix gets us back to how things used
to work before CloudFlare started compressing the responses.

Signed-off-by: Andy Doan <[email protected]>
  • Loading branch information
doanac committed Apr 9, 2024
1 parent bdd7d46 commit 3a45e61
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,13 @@ func NewApiClient(serverUrl string, config Config, caCertPath string, version st
InsecureSkipVerify: config.InsecureSkipVerify,
}
http.DefaultTransport.(*http.Transport).TLSClientConfig = tlsCfg
// targets/artifacts.go needs to know the Content-Length in order to
// compute the download progress. If certain services like CloudFlare
// see the client accepts compressed responsed (content-encoding not
// content-type) then it will give a compressed response. Golang will
// automagically decompress as you read the response *and* set
// content-length to -1 thereby breaking our download progress logic
http.DefaultTransport.(*http.Transport).DisableCompression = true
if len(caCertPath) > 0 {
rootCAs, _ := x509.SystemCertPool()
if rootCAs == nil {
Expand Down

0 comments on commit 3a45e61

Please sign in to comment.