Use OPTIONS
request before falling back to HEAD
request when trying to connect to repositories during normalization.
#4506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
To test if a repository is reachable we currently do a HEAD request. Unfortunately a HEAD request is just as slow as a GET on artifactory.
OPTIONS
is much faster, but it does not take authentication into account and is not always supported (thinking about reverse-proxies)With this PR we now try an OPTIONS request first, if that returns 200 we accept that the server is reachable. If an error is returned we first try a HEAD request to see if that returns a 200 (in case of maven central OPTIONS gives an error, while HEAD returns 200)
If that is OK we set
knownToExist
to true.We still first try https before (maybe) trying the original url.
What's your motivation?
Some artifactory repositories are VERY slow at directory listing.
Anything in particular you'd like reviewers to focus on?
knownToExist
is now true in most cases, even if the authentication would fail. This might not work as expected, but I'm not entirely sure what that is used for. Technically a 200 response from OPTIONS would mean it exists.Anyone you would like to review specifically?
@sambsnyd @timtebeek
Have you considered any alternatives or workarounds?
Increasing the timeout (which seems to not yet be used in this part of the code) but that leaves this to be very slow.
Any additional context
Checklist