mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +01:00
lib{store,fetchers}: Pass URLs specified directly verbatim to FileTransferRequest
The URL should not be normalized before handing it off to cURL, because builtin fetchers like fetchTarball/fetchurl are expected to work with arbitrary URLs, that might not be RFC3986 compliant. For those cases Nix should not normalize URLs, though validation is fine. ParseURL and cURL are supposed to match the set of acceptable URLs, since they implement the same RFC.
This commit is contained in:
parent
2746985d90
commit
e548700010
8 changed files with 84 additions and 14 deletions
|
|
@ -37,7 +37,7 @@ static void builtinFetchurl(const BuiltinBuilderContext & ctx)
|
|||
|
||||
auto fetch = [&](const std::string & url) {
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
FileTransferRequest request(parseURL(url));
|
||||
FileTransferRequest request(ValidURL{url});
|
||||
request.decompress = false;
|
||||
|
||||
auto decompressor = makeDecompressionSink(unpack && hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink);
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ struct curlFileTransfer : public FileTransfer
|
|||
|
||||
void enqueueItem(std::shared_ptr<TransferItem> item)
|
||||
{
|
||||
if (item->request.data && item->request.uri.scheme != "http" && item->request.uri.scheme != "https")
|
||||
if (item->request.data && item->request.uri.scheme() != "http" && item->request.uri.scheme() != "https")
|
||||
throw nix::Error("uploading to '%s' is not supported", item->request.uri.to_string());
|
||||
|
||||
{
|
||||
|
|
@ -801,11 +801,11 @@ struct curlFileTransfer : public FileTransfer
|
|||
void enqueueFileTransfer(const FileTransferRequest & request, Callback<FileTransferResult> callback) override
|
||||
{
|
||||
/* Ugly hack to support s3:// URIs. */
|
||||
if (request.uri.scheme == "s3") {
|
||||
if (request.uri.scheme() == "s3") {
|
||||
// FIXME: do this on a worker thread
|
||||
try {
|
||||
#if NIX_WITH_S3_SUPPORT
|
||||
auto parsed = ParsedS3URL::parse(request.uri);
|
||||
auto parsed = ParsedS3URL::parse(request.uri.parsed());
|
||||
|
||||
std::string profile = parsed.profile.value_or("");
|
||||
std::string region = parsed.region.value_or(Aws::Region::US_EAST_1);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ extern const unsigned int RETRY_TIME_MS_DEFAULT;
|
|||
|
||||
struct FileTransferRequest
|
||||
{
|
||||
ParsedURL uri;
|
||||
ValidURL uri;
|
||||
Headers headers;
|
||||
std::string expectedETag;
|
||||
bool verifyTLS = true;
|
||||
|
|
@ -85,8 +85,8 @@ struct FileTransferRequest
|
|||
std::string mimeType;
|
||||
std::function<void(std::string_view data)> dataCallback;
|
||||
|
||||
FileTransferRequest(ParsedURL uri)
|
||||
: uri(uri)
|
||||
FileTransferRequest(ValidURL uri)
|
||||
: uri(std::move(uri))
|
||||
, parentAct(getCurActivity())
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue