mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-12-01 12:13:00 +03:00
Disabling automatic UA if user defines one
This commit is contained in:
parent
d350217bce
commit
0bebb4aec3
@ -1,5 +1,9 @@
|
||||
package customheader
|
||||
|
||||
import (
|
||||
"github.com/projectdiscovery/stringsutil"
|
||||
)
|
||||
|
||||
// CustomHeaders valid for all requests
|
||||
type CustomHeaders []string
|
||||
|
||||
@ -13,3 +17,14 @@ 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(customHeader, header) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -31,7 +31,7 @@ require (
|
||||
github.com/projectdiscovery/retryabledns v1.0.12 // indirect
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.2-0.20210526144436-e15804ddc7dc
|
||||
github.com/projectdiscovery/sliceutil v0.0.0-20210804143453-61f3e7fd43ea
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210805190935-3d83726391c1
|
||||
github.com/projectdiscovery/wappalyzergo v0.0.12
|
||||
github.com/remeh/sizedwaitgroup v1.0.0
|
||||
|
2
go.sum
2
go.sum
@ -187,6 +187,8 @@ github.com/projectdiscovery/sliceutil v0.0.0-20210804143453-61f3e7fd43ea/go.mod
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210524051937-51dabe3b72c0/go.mod h1:TVSdZC0rRQeMIbsNSiGPhbmhyRtxqqtAGA9JiiNp2r4=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe h1:tQTgf5XLBgZbkJDPtnV3SfdP9tzz5ZWeDBwv8WhnH9Q=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9 h1:xbL1/7h0k6HE3RzPdYk9W/8pUxESrGWewTaZdIB5Pes=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I=
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210805190935-3d83726391c1 h1:9dYmONRtwy+xP8UAGHxEQ0cxO3umc9qiFmnYsoDUps4=
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210805190935-3d83726391c1/go.mod h1:oXLErqOpqEAp/ueQlknysFxHO3CUNoSiDNnkiHG+Jpo=
|
||||
github.com/projectdiscovery/wappalyzergo v0.0.12 h1:/xSsQBa1Ibt72bsHtUP6zHRZL1yyflj+rANdJ4QuRdI=
|
||||
|
@ -91,7 +91,11 @@ func New(options *Options) (*Runner, error) {
|
||||
httpxOptions.UnsafeURI = options.RequestURI
|
||||
httpxOptions.CdnCheck = options.OutputCDN
|
||||
httpxOptions.ExcludeCdn = options.ExcludeCDN
|
||||
httpxOptions.RandomAgent = options.RandomAgent
|
||||
if options.CustomHeaders.Has("User-Agent:") {
|
||||
httpxOptions.RandomAgent = false
|
||||
} else {
|
||||
httpxOptions.RandomAgent = options.RandomAgent
|
||||
}
|
||||
httpxOptions.Deny = options.Deny
|
||||
httpxOptions.Allow = options.Allow
|
||||
httpxOptions.MaxResponseBodySizeToSave = int64(options.MaxResponseBodySizeToSave)
|
||||
|
Loading…
Reference in New Issue
Block a user