From 093db64519ba701de99a9e09837d76241ac2061b Mon Sep 17 00:00:00 2001 From: Roman Karwacik Date: Tue, 23 Jan 2024 15:25:11 +0100 Subject: [PATCH] Add warning when using template with HTTP/2 and flag --disable-http2 --- cmd/fuzz/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/fuzz/main.go b/cmd/fuzz/main.go index 2c57cef..5a23145 100644 --- a/cmd/fuzz/main.go +++ b/cmd/fuzz/main.go @@ -1,6 +1,7 @@ package fuzz import ( + "bufio" "bytes" "context" "errors" @@ -196,6 +197,23 @@ func (opts *Options) valid() (err error) { } } + if opts.DisableHTTP2 && opts.Request.TemplateFile != "" { + file, err := os.Open(opts.Request.TemplateFile) + if err != nil { + return err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + + scanner.Scan() + firstLine := scanner.Text() + + if strings.Contains(string(firstLine), "HTTP/2") { + fmt.Fprint(os.Stderr, reporter.Dim("Warning: Template contains HTTP/2 request, but --disable-http2 is set. HTTP/1.1 will be used.\n")) + } + } + return nil }