Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings, possible linter failures and typos #223

Merged
merged 14 commits into from
Aug 8, 2024
Merged
9 changes: 4 additions & 5 deletions modules/l4http/httpmatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,19 @@ func (m MatchHTTP) handleHttp2WithPriorKnowledge(reader io.Reader, req *http.Req

// read the first 10 frames until we get a headers frame (skipping settings, window update & priority frames)
var frame http2.Frame
for i := 0; i < 10; i++ {
maxAttempts := 10
for i := 0; i < maxAttempts; i++ {
frame, err = framer.ReadFrame()
if err != nil {
return err
}
if frame.Header().Type == http2.FrameHeaders {
break
} else if i == maxAttempts-1 {
vnxme marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("failed to read a http2 headers frame after %d attempts", maxAttempts)
}
}

if frame.Header().Type != http2.FrameHeaders {
return fmt.Errorf("failed to read a http2 headers frame after 10 attempts")
}

decoder := hpack.NewDecoder(4096, nil) // max table size 4096 from http2.initialHeaderTableSize
headers, err := decoder.DecodeFull((frame.(*http2.HeadersFrame)).HeaderBlockFragment())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion modules/l4tee/tee.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (t *Handler) Provision(ctx caddy.Context) error {
if err != nil {
return err
}
var handlers layer4.Handlers
handlers := make(layer4.Handlers, 0)
for _, mod := range mods.([]interface{}) {
handlers = append(handlers, mod.(layer4.NextHandler))
}
Expand Down