]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests/http2: add test for content-encoding case insensitivity master 3265/head
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 23 Jul 2026 07:28:04 +0000 (09:28 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 5 Aug 2026 15:01:29 +0000 (15:01 +0000)
Ticket: 8760

tests/http2-deflate-case/README.md [new file with mode: 0644]
tests/http2-deflate-case/input.pcap [new file with mode: 0644]
tests/http2-deflate-case/server.go [new file with mode: 0644]
tests/http2-deflate-case/test.yaml [new file with mode: 0644]

diff --git a/tests/http2-deflate-case/README.md b/tests/http2-deflate-case/README.md
new file mode 100644 (file)
index 0000000..78e3edc
--- /dev/null
@@ -0,0 +1,10 @@
+# Description
+
+Test http2 content-encoding case insensitivity
+
+https://redmine.openinfosecfoundation.org/issues/8760
+
+# PCAP
+
+The pcap comes from running dummy HTTP2 server with `go run server.go`
+and client `curl --compressed -H 'Accept-Encoding: deflate' --http2 127.0.0.1:8080/` and seeing the decompressed output
diff --git a/tests/http2-deflate-case/input.pcap b/tests/http2-deflate-case/input.pcap
new file mode 100644 (file)
index 0000000..42560ff
Binary files /dev/null and b/tests/http2-deflate-case/input.pcap differ
diff --git a/tests/http2-deflate-case/server.go b/tests/http2-deflate-case/server.go
new file mode 100644 (file)
index 0000000..96cf2ff
--- /dev/null
@@ -0,0 +1,33 @@
+package main
+
+import (
+       "compress/flate"
+       "fmt"
+       "golang.org/x/net/http2"
+       "golang.org/x/net/http2/h2c"
+       "net/http"
+)
+
+func main() {
+       h2s := &http2.Server{}
+
+       handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+               h := w.Header()
+               h["content-encoding"] = []string{"DeFlate"}
+               fw, err := flate.NewWriter(w, 1)
+               if err != nil {
+                       fmt.Fprintf(w, "FAIL %s, %v, http: %v", err, r.URL.Path, r.TLS == nil)
+               }
+               fmt.Fprintf(fw, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil)
+               fw.Flush()
+       })
+
+       server := &http.Server{
+               Addr:    "0.0.0.0:8080",
+               Handler: h2c.NewHandler(handler, h2s),
+       }
+
+       fmt.Printf("Listening [0.0.0.0:8080]...\n")
+       err := server.ListenAndServe()
+       fmt.Printf("lol %s", err)
+}
diff --git a/tests/http2-deflate-case/test.yaml b/tests/http2-deflate-case/test.yaml
new file mode 100644 (file)
index 0000000..082cdd5
--- /dev/null
@@ -0,0 +1,20 @@
+requires:
+  min-version: 9
+
+args:
+  - -k none
+
+checks:
+
+  # Check that there is one file event with decompressed length.
+  - filter:
+      count: 1
+      match:
+        event_type: fileinfo
+        http.length: 30
+        http.version: "2"
+        fileinfo.size: 20
+  - filter:
+      count: 0
+      match:
+        event_type: anomaly