diff --git a/pkg/hub/hub.go b/pkg/hub/hub.go index 0386fc3..e062838 100644 --- a/pkg/hub/hub.go +++ b/pkg/hub/hub.go @@ -135,10 +135,15 @@ func PatchRepository(repository *types.Repository, token *types.Token) (*types.R if err != nil { return nil, fmt.Errorf("Can not create http request to update file: %v", err) } - req.Header.Add("Authorization", fmt.Sprintf("JWT %v", token.Token)) + + // Disable gzip compression: + // - https://stackoverflow.com/questions/33469723/go-how-to-control-gzip-compression-when-sending-http-request + req.Header.Set("Accept-Encoding", "identity") + + req.Header.Set("Authorization", fmt.Sprintf("JWT %v", token.Token)) + req.Header.Set("Content-Length", strconv.Itoa(len(data.Encode()))) //req.Header.Add("Content-Type", "application/json") - req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode()))) - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") resp, err := client.Do(req) if err != nil { diff --git a/pkg/hub/hub_test.go b/pkg/hub/hub_test.go index a0541dc..a34a2b4 100644 --- a/pkg/hub/hub_test.go +++ b/pkg/hub/hub_test.go @@ -7,13 +7,10 @@ import ( "github.com/stretchr/testify/require" "github.com/volker-raschek/docker-hub-description-updater/pkg/hub" "github.com/volker-raschek/docker-hub-description-updater/pkg/types" - flogger "github.com/volker-raschek/go-logger/pkg/logger" ) func TestPatchRepository(t *testing.T) { - hub.SetLogger(flogger.NewDefaultLogger(flogger.LogLevelDebug)) - dockerHubUser := os.Getenv("REGISTRY_USER") if len(dockerHubUser) <= 0 { t.Fatalf("Environment variable REGISTRY_USER is empty")