Skip to content

Commit

Permalink
resolve semantic conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed Sep 6, 2023
1 parent 8e88ea4 commit 75ffa7b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packetbeat/protos/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package http
import (
"bytes"
"encoding/base64"
"errors"
"fmt"
"net"
"net/url"
Expand Down Expand Up @@ -760,13 +759,26 @@ func extractHostHeader(header string) (host string, port int) {
}

func trimSquareBracket(s string) string {
s, ok := strings.CutPrefix(s, "[")
s, ok := stringsCutPrefix(s, "[")
if !ok {
return s
}
return strings.TrimSuffix(s, "]")
}

// stringsCutPrefix is copied from the standard library strings package as 7.17 is not built
// with go1.20 when strings.CutPrefix was added.
//
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
func stringsCutPrefix(s, prefix string) (after string, found bool) {
if !strings.HasPrefix(s, prefix) {
return s, false
}
return s[len(prefix):], true
}

func (http *httpPlugin) hideHeaders(m *message) {
for _, header := range http.redactHeaders {
if _, exists := m.headers[header]; exists {
Expand Down

0 comments on commit 75ffa7b

Please sign in to comment.