Skip to content

Propagate unsupported error when server returns 200 #5

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

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

charliermarsh
Copy link
Contributor

Summary

It looks like Artifactory has some issues related to range requests:

Specifically, the server returns Accept-Ranges: bytes:

❯ curl -I https://killjoyuvbug.jfrog.io/artifactory/api/pypi/pypi/packages/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl
HTTP/1.1 200
Date: Sat, 17 Feb 2024 04:25:58 GMT
Content-Type: application/octet-stream
Content-Length: 62574
Connection: keep-alive
X-JFrog-Version: Artifactory/7.78.3 77803900
X-Artifactory-Id: 1271c5d73fe90d4835ba98b07ae9fae097684c20
X-Artifactory-Node-Id: a0sl0mjfkim76-artifactory-primary-0
Last-Modified: Mon, 22 May 2023 15:12:44 GMT
ETag: 60b928b15e05d04a33b880a0232e44258c777740
X-Checksum-Sha1: 60b928b15e05d04a33b880a0232e44258c777740
X-Checksum-Sha256: 58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f
X-Checksum-Md5: 0cb4b772a1a652cf3d170a6c42a69098
Accept-Ranges: bytes
X-Artifactory-Filename: requests-2.31.0-py3-none-any.whl
Content-Disposition: attachment; filename="requests-2.31.0-py3-none-any.whl"
X-Request-ID: b93813a7cd7abb1091fdd293875864bb

But if you then make a range request, it returns a 200, and it appears to stream the entire file back to you:

> GET /artifactory/api/pypi/pypi/packages/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl HTTP/1.1
> Host: killjoyuvbug.jfrog.io
> User-Agent: curl/8.4.0
> Accept: */*
> Range:bytes=100-200

< HTTP/1.1 200
< Date: Sat, 17 Feb 2024 04:26:28 GMT
< Content-Type: application/octet-stream
< Content-Length: 62574
< Connection: keep-alive
< X-JFrog-Version: Artifactory/7.78.3 77803900
< X-Artifactory-Id: 1271c5d73fe90d4835ba98b07ae9fae097684c20
< X-Artifactory-Node-Id: a0sl0mjfkim76-artifactory-primary-0
< Last-Modified: Mon, 22 May 2023 15:12:44 GMT
< ETag: 60b928b15e05d04a33b880a0232e44258c777740
< X-Checksum-Sha1: 60b928b15e05d04a33b880a0232e44258c777740
< X-Checksum-Sha256: 58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f
< X-Checksum-Md5: 0cb4b772a1a652cf3d170a6c42a69098
< Accept-Ranges: bytes
< X-Artifactory-Filename: requests-2.31.0-py3-none-any.whl
< Content-Disposition: attachment; filename="requests-2.31.0-py3-none-any.whl"
< X-Request-ID: 4233f1f418add9e1c86ebec61a7db773

This PR validates that the responses returned once we start streaming are in fact 206s.

@baszalmstra
Copy link
Collaborator

Thanks @charliermarsh this looks great!

@baszalmstra baszalmstra merged commit a14e65d into prefix-dev:main Feb 17, 2024
@github-actions github-actions bot mentioned this pull request Feb 17, 2024
charliermarsh added a commit to astral-sh/uv that referenced this pull request Feb 17, 2024
## Summary

There are more details in #1370,
but it looks like Artifactory servers have incorrect behavior when it
comes to HTTP range requests, in that they return `Accept-Ranges:
bytes`, but then incorrectly return 200 requests when you actually ask
for a given range.

This PR ensures that we fallback gracefully in this case. It's built on
prefix-dev/async_http_range_reader#5. Assuming
that gets merged upstream, we can then remove the Git dependency.

Closes #1370.

## Test Plan

`cargo run pip install requests -i
https://killjoyuvbug.jfrog.io/artifactory/api/pypi/pypi/simple
--verbose`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants