Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpclient.DoRequest retry logic ignores value of closeBody #866

Open
bradmac-ats opened this issue Dec 4, 2023 · 0 comments
Open

httpclient.DoRequest retry logic ignores value of closeBody #866

bradmac-ats opened this issue Dec 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@bradmac-ats
Copy link

bradmac-ats commented Dec 4, 2023

Describe the bug

the retry logic in httpclient.DoRequest always calls SendPost, regardless of the value of closeBody. I believe it needs a conditional to call SendPostLeaveBodyOpen when closeBody == false.

Current behavior

response body is read in redirect's retry logic, and then is attempted to be read again by utils.ExecAqlSaveToFile, leading to a confusing EOF error after getting a 200 response

[Debug] Sending HTTP GET request to: http://atscorp.jfrog.io/artifactory/api/system/version  
[Debug] Artifactory response: 200 
[Debug] JFrog Artifactory version is: 7.74.3                                                                                                                                                               
[Debug] Searching Artifactory using AQL query:                                                                                                                                                             
 items.find({"repo":{"$eq":"ipt-mvn-release-local"},"name":{"$match":"rest-api-starter-*"}}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created").limit(10)
[Debug] Sending HTTP POST request to: http://atscorp.jfrog.io/artifactory/api/search/aql                                                                                                                   
[Debug] HTTP redirecting to https://atscorp.jfrog.io/artifactory/api/search/aql
[Debug] Sending HTTP POST request to: https://atscorp.jfrog.io/artifactory/api/search/aql
[Debug] Artifactory response: 200 
[Debug] Streaming data to file...
panic: http: read on closed response body

goroutine 1 [running]:
main.importArtifacts()
        C:/Users/bradmac/git/Utilities/gitlab-migration-utilities/cmd/import-artifactory-artifacts/import-artifactory-artifacts.go:151 +0x305
main.main()
        C:/Users/bradmac/git/Utilities/gitlab-migration-utilities/cmd/import-artifactory-artifacts/import-artifactory-artifacts.go:39 +0x4a

Process finished with the exit code 2

Reproduction steps

specify an http url instead of https, which leads to a redirect to https

rtDetails := auth.NewArtifactoryDetails()
rtDetails.SetUrl("http://atscorp.jfrog.io/artifactory/")

Expected behavior

either a seamless redirect or a useful error

JFrog Client-Go version

v1.35.0

JFrog CLI version (if applicable)

No response

Operating system type and version

Windows 11

JFrog Artifactory version

7.74.3

JFrog Xray version

No response

@bradmac-ats bradmac-ats added the bug Something isn't working label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant