···4646 urls ? []
47474848, # Additional curl options needed for the download to succeed.
4949+ # Warning: Each space (no matter the escaping) will start a new argument.
5050+ # If you wish to pass arguments with spaces, use `curlOptsList`
4951 curlOpts ? ""
5252+5353+, # Additional curl options needed for the download to succeed.
5454+ curlOptsList ? []
50555156, # Name of the file. If empty, use the basename of `url' (or of the
5257 # first element of `urls').
···147152148153 outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
149154150150- inherit curlOpts showURLs mirrorsFile postFetch downloadToTemp executable;
155155+ curlOpts = lib.warnIf (lib.isList curlOpts) ''
156156+ fetchurl for ${toString (builtins.head urls_)}: curlOpts is a list (${lib.generators.toPretty { multiline = false; } curlOpts}), which is not supported anymore.
157157+ - If you wish to get the same effect as before, for elements with spaces (even if escaped) to expand to multiple curl arguments, use a string argument instead:
158158+ curlOpts = ${lib.strings.escapeNixString (toString curlOpts)};
159159+ - If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
160160+ curlOptsList = [ ${lib.concatMapStringsSep " " lib.strings.escapeNixString curlOpts} ];'' curlOpts;
161161+ curlOptsList = lib.escapeShellArgs curlOptsList;
162162+ inherit showURLs mirrorsFile postFetch downloadToTemp executable;
151163152164 impureEnvVars = impureEnvVars ++ netrcImpureEnvVars;
153165
+13
pkgs/build-support/fetchurl/tests.nix
···11+{ invalidateFetcherByDrvHash, fetchurl, jq, moreutils, ... }: {
22+ # Tests that we can send custom headers with spaces in them
33+ header =
44+ let headerValue = "Test '\" <- These are some quotes";
55+ in invalidateFetcherByDrvHash fetchurl {
66+ url = "https://httpbin.org/headers";
77+ sha256 = builtins.hashString "sha256" (headerValue + "\n");
88+ curlOptsList = [ "-H" "Hello: ${headerValue}" ];
99+ postFetch = ''
1010+ ${jq}/bin/jq -r '.headers.Hello' $out | ${moreutils}/bin/sponge $out
1111+ '';
1212+ };
1313+}