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

Support range requests when downloading files #1021

Open
zanieb opened this issue Dec 19, 2023 · 3 comments
Open

Support range requests when downloading files #1021

zanieb opened this issue Dec 19, 2023 · 3 comments

Comments

@zanieb
Copy link

zanieb commented Dec 19, 2023

The devpi server does not appear to support HTTP range requests when downloading files from the index. This can result in a significant slowdown of downloads during package resolution.

Are there blockers for supporting this?

@fschulze
Copy link
Contributor

In what way are range requests used for package resolution?

There are no blockers I can think of right now, but it isn't trivial to implement fully. A first step would be to implement it when the file exists locally. If it has to be streamed from the primary server in a replicated setup or from a mirror, then it would require a possibly much more complex implementation.

I'm uncertain about the usefulness though, as it is much easier in most cases to put nginx in front and let it handle files directly. This only works with the default storage backend though.

@zanieb
Copy link
Author

zanieb commented Dec 20, 2023

In what way are range requests used for package resolution?

For servers that do not support PEP 658, we need to download a wheel to determine package metadata for resolution. We can use range requests to download the necessary portion of the wheel instead of the entire thing.

pip does this e.g. https://github.com/pypa/pip/blob/e88d39ae49ab11a8b80609a018e5a36ea4ccad89/src/pip/_internal/network/lazy_wheel.py#L23-L37

I agree in production it'd make sense to place nginx in front of the server, but I'm just trying to run a lightweight server for testing purposes (which seems like a good part of the intent of this project).

@fschulze
Copy link
Contributor

It should be fairly straight forward to add this to _pkgserv as long as you don't involve the should_fetch_remote_file branch. Maybe there even already is support for that when serving static files with pyramid, I didn't check yet. Basically at the end of the function where we check for HEAD requests one could check for range requests and return accordingly.

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

No branches or pull requests

2 participants