From 8870ee8b5e9c8d55771ce9f8da05880434379130 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 24 Oct 2024 14:22:53 +0530 Subject: [PATCH] add redirect logic --- registry-automation/cmd/utils.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/registry-automation/cmd/utils.go b/registry-automation/cmd/utils.go index feebc3a1..0d4128ff 100644 --- a/registry-automation/cmd/utils.go +++ b/registry-automation/cmd/utils.go @@ -18,7 +18,15 @@ func generateGCPObjectName(namespace, connectorName, version string) string { func downloadFile(sourceURL, destination string, headers map[string]string) error { // Create a new HTTP client - client := &http.Client{} + client := &http.Client{ + CheckRedirect: func(req *http.Request, via []*http.Request) error { + // Copy headers to redirected request + for key, values := range headers { + req.Header.Set(key, values) + } + return nil + }, + } // Create a new GET request req, err := http.NewRequest("GET", sourceURL, nil)