A Nix flake for h2spec, the HTTP/2 conformance testing tool.
h2spec is compliant with RFC 7540 (HTTP/2) and RFC 7541 (HPACK).
nix run github:mrrubinos/h2spec -- -h 127.0.0.1 -p 8080nix profile install github:mrrubinos/h2specAdd to your flake.nix inputs:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
h2spec = {
url = "github:mrrubinos/h2spec";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, h2spec, ... }: {
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit h2spec; };
modules = [ ./configuration.nix ];
};
};
}Then in configuration.nix:
{ pkgs, h2spec, ... }:
{
environment.systemPackages = [
h2spec.packages.${pkgs.system}.default
];
}If you prefer pkgs.h2spec to be available throughout your configuration:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
h2spec = {
url = "github:mrrubinos/h2spec";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, h2spec, ... }: {
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{
nixpkgs.overlays = [
(final: prev: {
h2spec = h2spec.packages.${prev.system}.default;
})
];
}
./configuration.nix
];
};
};
}Then use it anywhere:
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.h2spec ];
}{ pkgs, h2spec, ... }:
{
home.packages = [
h2spec.packages.${pkgs.system}.default
];
}{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
h2spec.url = "github:mrrubinos/h2spec";
};
outputs = { self, nixpkgs, h2spec, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
buildInputs = [
h2spec.packages.${system}.default
];
};
};
}# Basic conformance test
h2spec -h 127.0.0.1 -p 8080
# TLS mode (skip certificate verification)
h2spec -h 127.0.0.1 -p 8443 -t -k
# Verbose output
h2spec -h 127.0.0.1 -p 8080 -v
# Strict mode (includes SHOULD requirements from RFC)
h2spec -h 127.0.0.1 -p 8080 -S
# Run specific test sections
h2spec -h 127.0.0.1 -p 8080 http2 # All HTTP/2 tests
h2spec -h 127.0.0.1 -p 8080 http2/6.1 # HEADERS frame
h2spec -h 127.0.0.1 -p 8080 http2/6.9 # WINDOW_UPDATE
h2spec -h 127.0.0.1 -p 8080 hpack # HPACK compression
# Generate JUnit report (useful for CI)
h2spec -h 127.0.0.1 -p 8080 -j report.xml
# List all tests without running
h2spec --dryrun| Spec ID | Description |
|---|---|
generic |
Generic HTTP/2 server test cases |
http2 |
RFC 7540 (HTTP/2) compliance tests |
hpack |
RFC 7541 (HPACK compression) tests |
| Package | Description |
|---|---|
h2spec |
Built from source (default) |
x86_64-linuxaarch64-linuxx86_64-darwinaarch64-darwin
Your HTTP/2 server must:
- Respond to
GET /andPOST /requests - Return status
200 - Return a non-empty response body
defmodule TestPlug do
import Plug.Conn
def init(opts), do: opts
def call(conn, _opts) do
conn
|> put_resp_content_type("text/plain")
|> send_resp(200, "OK")
end
end
# Start server
Bandit.start_link(plug: TestPlug, port: 8080)Then run:
h2spec -h 127.0.0.1 -p 8080If you clone this repository and want to build locally:
nix build .#h2spec
./result/bin/h2spec --versionThis flake is licensed under the MIT License.
h2spec itself is also MIT licensed.
- h2spec - The upstream project