Skip to content

Commit

Permalink
lazy-wheel: allow redirects for HEAD request
Browse files Browse the repository at this point in the history
Resolves: #9039
(cherry picked from commit 7bf0ee7)
  • Loading branch information
thatch authored and radoering committed Mar 2, 2024
1 parent 58995de commit 33b7618
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/poetry/inspection/lazy_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ def _content_length_from_head(self) -> int:
:raises HTTPRangeRequestUnsupported: if the response fails to indicate support
for "bytes" ranges."""
self._request_count += 1
head = self._session.head(self._url, headers=self._uncached_headers())
head = self._session.head(
self._url, headers=self._uncached_headers(), allow_redirects=True
)
head.raise_for_status()
assert head.status_code == codes.ok
accepted_range = head.headers.get("Accept-Ranges", None)
Expand Down
10 changes: 10 additions & 0 deletions tests/inspection/test_lazy_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ def test_metadata_from_wheel_url_with_redirect(
)


def test_metadata_from_wheel_url_with_redirect_after_500(
assert_metadata_from_wheel_url: AssertMetadataFromWheelUrl,
) -> None:
assert_metadata_from_wheel_url(
negative_offset_error=(codes.internal_server_error, b"Internal server error"),
expected_requests=10,
redirect=True,
)


@pytest.mark.parametrize(
("negative_offset_failure", "expected_requests"),
[
Expand Down

0 comments on commit 33b7618

Please sign in to comment.