Skip to content

Commit

Permalink
Add warning when using template with HTTP/2 and flag --disable-http2
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpt-romankarwacik authored and rtpt-alexanderneumann committed Jan 24, 2024
1 parent ce6e049 commit 093db64
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/fuzz/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fuzz

import (
"bufio"
"bytes"
"context"
"errors"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 093db64

Please sign in to comment.