diff --git a/.github/win/windows-installer-v8-x64.iss b/.github/win/windows-installer-v8-x64.iss index c11acb04151..29f8f652d03 100644 --- a/.github/win/windows-installer-v8-x64.iss +++ b/.github/win/windows-installer-v8-x64.iss @@ -5,8 +5,8 @@ AppName=Cloud Foundry CLI AppVersion=VERSION AppVerName=Cloud Foundry CLI version VERSION AppPublisher=Cloud Foundry Foundation -ArchitecturesInstallIn64BitMode=x64 ia64 -ArchitecturesAllowed=x64 ia64 +ArchitecturesInstallIn64BitMode=x64compatible +ArchitecturesAllowed=x64compatible PrivilegesRequired=none DefaultDirName={pf}\Cloud Foundry SetupIconFile=cf.ico diff --git a/api/cloudcontroller/ccv3/request.go b/api/cloudcontroller/ccv3/request.go index dc799fc59ec..65b988ac784 100644 --- a/api/cloudcontroller/ccv3/request.go +++ b/api/cloudcontroller/ccv3/request.go @@ -3,6 +3,7 @@ package ccv3 import ( "io" "net/http" + "strings" "code.cloudfoundry.org/cli/api/cloudcontroller" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" @@ -57,6 +58,7 @@ func (requester *RealRequester) newHTTPRequest(passedRequest requestOptions) (*c } request.Header = http.Header{} + if passedRequest.Header != nil { request.Header = passedRequest.Header } @@ -69,9 +71,15 @@ func (requester *RealRequester) newHTTPRequest(passedRequest requestOptions) (*c request.Header.Set("Accept", "application/json") } - if request.Header.Get("Content-Type") == "" { + if !isDownloadDroplet(passedRequest.URL, passedRequest.RequestName) && request.Header.Get("Content-Type") == "" { request.Header.Set("Content-Type", "application/json") + } else if isDownloadDroplet(passedRequest.URL, passedRequest.RequestName) && request.Header.Get("Content-Type") != "" { + request.Header.Del("Content-Type") } return cloudcontroller.NewRequest(request, passedRequest.Body), nil } + +func isDownloadDroplet(URL string, requestName string) bool { + return (strings.Contains(URL, "droplet") && strings.Contains(URL, "download")) || (requestName == internal.GetDropletBitsRequest) +} diff --git a/api/cloudcontroller/ccv3/requester_test.go b/api/cloudcontroller/ccv3/requester_test.go index 9eb78324da7..6b078ece01b 100644 --- a/api/cloudcontroller/ccv3/requester_test.go +++ b/api/cloudcontroller/ccv3/requester_test.go @@ -1069,6 +1069,9 @@ var _ = Describe("shared request helpers", func() { CombineHandlers( VerifyRequest(http.MethodGet, "/v3/apps/some-app-guid/manifest"), VerifyHeaderKV("Accept", "application/x-yaml"), + func(w http.ResponseWriter, req *http.Request) { + Expect(req.Header).To(HaveKey("Content-Type"), "Header Content-Type is not present") + }, RespondWith( http.StatusOK, expectedResponseBody, @@ -1134,6 +1137,31 @@ var _ = Describe("shared request helpers", func() { }) }) }) + + Context("Download a droplet", func() { + BeforeEach(func() { + requestName = internal.GetDropletBitsRequest + uriParams = internal.Params{"droplet_guid": "some-droplet-guid"} + }) + + When("The server returns an unauthorized error", func() { + BeforeEach(func() { + server.AppendHandlers( + CombineHandlers( + VerifyRequest(http.MethodGet, "/v3/droplets/some-droplet-guid/download"), + func(w http.ResponseWriter, req *http.Request) { + Expect(req.Header).NotTo(HaveKey("Content-Type"), "Header Content-Type is present") + }, + RespondWith(http.StatusUnauthorized, "", http.Header{}), + ), + ) + }) + + It("fails", func() { + Expect(executeErr).To(HaveOccurred()) + }) + }) + }) }) Describe("MakeRequestSendRaw", func() { diff --git a/cf/api/buildpack_bits.go b/cf/api/buildpack_bits.go index a3dd4416071..da6efd357eb 100644 --- a/cf/api/buildpack_bits.go +++ b/cf/api/buildpack_bits.go @@ -108,6 +108,7 @@ func (repo CloudControllerBuildpackBitsRepository) CreateBuildpackZipFile(buildp if err != nil { return nil, "", fmt.Errorf("%s: %s", T("Couldn't open buildpack file"), err.Error()) } + defer specifiedFile.Close() err = normalizeBuildpackArchive(specifiedFile, zipFileToUpload) if err != nil { return nil, "", zipErrorHelper(err) diff --git a/go.mod b/go.mod index 3a85e18f902..48a9f0a856b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module code.cloudfoundry.org/cli -go 1.22 +go 1.22.0 require ( code.cloudfoundry.org/bytefmt v0.0.0-20230612151507-41ef4d1f67a4