fix(pkg/hub): disable gzip compression for http requests
This commit is contained in:
parent
7e29d6f0aa
commit
b6e52111e5
@ -135,10 +135,15 @@ func PatchRepository(repository *types.Repository, token *types.Token) (*types.R
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Can not create http request to update file: %v", err)
|
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-Type", "application/json")
|
||||||
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,13 +7,10 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/volker-raschek/docker-hub-description-updater/pkg/hub"
|
"github.com/volker-raschek/docker-hub-description-updater/pkg/hub"
|
||||||
"github.com/volker-raschek/docker-hub-description-updater/pkg/types"
|
"github.com/volker-raschek/docker-hub-description-updater/pkg/types"
|
||||||
flogger "github.com/volker-raschek/go-logger/pkg/logger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPatchRepository(t *testing.T) {
|
func TestPatchRepository(t *testing.T) {
|
||||||
|
|
||||||
hub.SetLogger(flogger.NewDefaultLogger(flogger.LogLevelDebug))
|
|
||||||
|
|
||||||
dockerHubUser := os.Getenv("REGISTRY_USER")
|
dockerHubUser := os.Getenv("REGISTRY_USER")
|
||||||
if len(dockerHubUser) <= 0 {
|
if len(dockerHubUser) <= 0 {
|
||||||
t.Fatalf("Environment variable REGISTRY_USER is empty")
|
t.Fatalf("Environment variable REGISTRY_USER is empty")
|
||||||
|
Loading…
Reference in New Issue
Block a user