forked from NixOS/nixpkgs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#278380 from DeeUnderscore/fix/nginx-etag
nginx: change etags for statically compressed files served from store
- Loading branch information
Showing
5 changed files
with
80 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import ./make-test-python.nix { | ||
name = "nginx-etag-compression"; | ||
|
||
nodes.machine = { pkgs, lib, ... }: { | ||
services.nginx = { | ||
enable = true; | ||
recommendedGzipSettings = true; | ||
virtualHosts.default = { | ||
root = pkgs.runCommandLocal "testdir" {} '' | ||
mkdir "$out" | ||
cat > "$out/index.html" <<EOF | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
Hello, world! | ||
EOF | ||
${pkgs.gzip}/bin/gzip -k "$out/index.html" | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = { nodes, ... }: '' | ||
machine.wait_for_unit("nginx") | ||
machine.wait_for_open_port(80) | ||
etag_plain = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:' http://127.0.0.1/") | ||
etag_gzip = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:gzip' http://127.0.0.1/") | ||
with subtest("different representations have different etags"): | ||
assert etag_plain != etag_gzip, f"etags should differ: {etag_plain} == {etag_gzip}" | ||
with subtest("etag for uncompressed response is reproducible"): | ||
etag_plain_repeat = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:' http://127.0.0.1/") | ||
assert etag_plain == etag_plain_repeat, f"etags should be the same: {etag_plain} != {etag_plain_repeat}" | ||
with subtest("etag for compressed response is reproducible"): | ||
etag_gzip_repeat = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:gzip' http://127.0.0.1/") | ||
assert etag_gzip == etag_gzip_repeat, f"etags should be the same: {etag_gzip} != {etag_gzip_repeat}" | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters