Redirect to http resources by default #25
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#15 relates.
This introduces a binary flag on the router to allow you to toggle between streaming and redirect. Streaming makes sense when you are in an air-gapped environment (the original motivator), or when the server has authentication credentials which the client might not (e.g. simple-repository/simple-repository#35). Redirect makes sense when you are using
simple-repository-serverto handle repository merging (e.g. of public repositories), it would also makepip/uvcache more efficient (tested: pip shows that it is caching the non-redirected URL, but it actually caches the final URL) as the terminal URL will reachpip/uvand can be pooled with other requests to the same location (that don't go throughsimple-repository-server.In the future, I hope that #15 will address the ability to
get_resourceof a byte-stream (irrespective of source), allowing unknown protocols to work seamlessly. In that scenario, I hope the that the stream doesn't start until requested, and that there will be enough context to know that for http resources we might return a redirect response instead. In that world, it would be a component-level behaviour whether streaming is forced or not - if you want to disable redirecting, you simply hide the source URL in yourget_resourceresponse and the server can do nothing other than streaming. There, this flag would continue to make sense, but would be something we can move down into a component (and eventually remove from thebuild_routerfunction.