Commit 012e3374 by Brad Brown Committed by Sébastien Eustace

Fix: match legacy URL API documentation (#336)

As per
https://warehouse.pypa.io/api-reference/legacy/#get--simple--project--,
the project URL should have a trailing slash.

This was discovered as an issue in an edge case situation,
but should be the standard call regardless.

Edge case explanation:
In a private pypi instance built on artifactory,
set up to serve on https (443) and ignore http (80) requests,
artifactory sends a 301 redirect when called without the slash,
but provides the redirect url as http (due to a bug in artifactory).
This results in an almost-valid call (but missing the slash)
failing by being redirected to a nonsecure call that isn't answered.

For whatever it is worth, there is a Bug filed with Artifactory
for the bad redirect (https://www.jfrog.com/jira/browse/RTFACT-14235),
but it is over a year old with no movement.
parent 9a775995
......@@ -185,7 +185,7 @@ class LegacyRepository(PyPiRepository):
if self._cache.store("matches").has(key):
versions = self._cache.store("matches").get(key)
else:
page = self._get("/{}".format(canonicalize_name(name).replace(".", "-")))
page = self._get("/{}/".format(canonicalize_name(name).replace(".", "-")))
if page is None:
return []
......@@ -284,7 +284,7 @@ class LegacyRepository(PyPiRepository):
return package
def _get_release_info(self, name, version): # type: (str, str) -> dict
page = self._get("/{}".format(canonicalize_name(name).replace(".", "-")))
page = self._get("/{}/".format(canonicalize_name(name).replace(".", "-")))
if page is None:
raise ValueError('No package named "{}"'.format(name))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment