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

Use OPTIONS request before falling back to HEAD request when trying to connect to repositories during normalization. #4506

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pstreef
Copy link
Contributor

@pstreef pstreef commented Sep 20, 2024

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

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

…ng to connect to repositories during normalization.
@pstreef pstreef self-assigned this Sep 20, 2024
@pstreef pstreef added the enhancement New feature or request label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant