Files
projectdiscovery-httpx/common/customheader/customheader.go
T
Sami d491201eff Issue 735+issue 739 (#757)
* adding strings.ToLower to headers

* added validation logic for flags

* validated silent flag with incompatible flags

* silent flag bug fix

* added test case

* updated test case to include multiple headers
2022-09-13 16:46:38 +05:30

32 lines
642 B
Go

package customheader
import (
"strings"
"github.com/projectdiscovery/stringsutil"
)
// CustomHeaders valid for all requests
type CustomHeaders []string
// String returns just a label
func (c *CustomHeaders) String() string {
return "Custom Global Headers"
}
// Set a new global header
func (c *CustomHeaders) Set(value string) error {
*c = append(*c, value)
return nil
}
// Has checks if the list contains a header name
func (c *CustomHeaders) Has(header string) bool {
for _, customHeader := range *c {
if stringsutil.HasPrefixAny(strings.ToLower(customHeader), strings.ToLower(header)) {
return true
}
}
return false
}