depot/third_party/nixpkgs/pkgs/build-support/fetchurl/tests.nix
Default email ca5ab3a501 Project import generated by Copybara.
GitOrigin-RevId: 4a01ca36d6bfc133bc617e661916a81327c9bbc8
2022-07-14 08:49:19 -04:00

13 lines
522 B
Nix

{ invalidateFetcherByDrvHash, fetchurl, jq, moreutils, ... }: {
# Tests that we can send custom headers with spaces in them
header =
let headerValue = "Test '\" <- These are some quotes";
in invalidateFetcherByDrvHash fetchurl {
url = "https://httpbin.org/headers";
sha256 = builtins.hashString "sha256" (headerValue + "\n");
curlOptsList = [ "-H" "Hello: ${headerValue}" ];
postFetch = ''
${jq}/bin/jq -r '.headers.Hello' $out | ${moreutils}/bin/sponge $out
'';
};
}