mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 14:35:26 +00:00
use sync.Once
This commit is contained in:
parent
50023428d0
commit
46782ff90c
@ -29,10 +29,10 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
rawHttpClient *rawhttp.Client
|
rawHttpClient *rawhttp.Client
|
||||||
|
rawHttpClientOnce sync.Once
|
||||||
forceMaxRedirects int
|
forceMaxRedirects int
|
||||||
normalClient *retryablehttp.Client
|
normalClient *retryablehttp.Client
|
||||||
clientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
|
clientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
|
||||||
rawHttpClientMu sync.Mutex
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init initializes the clientpool implementation
|
// Init initializes the clientpool implementation
|
||||||
@ -148,10 +148,7 @@ func (c *Configuration) HasStandardOptions() bool {
|
|||||||
|
|
||||||
// GetRawHTTP returns the rawhttp request client
|
// GetRawHTTP returns the rawhttp request client
|
||||||
func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
||||||
rawHttpClientMu.Lock()
|
rawHttpClientOnce.Do(func() {
|
||||||
defer rawHttpClientMu.Unlock()
|
|
||||||
|
|
||||||
if rawHttpClient == nil {
|
|
||||||
rawHttpOptions := rawhttp.DefaultOptions
|
rawHttpOptions := rawhttp.DefaultOptions
|
||||||
if types.ProxyURL != "" {
|
if types.ProxyURL != "" {
|
||||||
rawHttpOptions.Proxy = types.ProxyURL
|
rawHttpOptions.Proxy = types.ProxyURL
|
||||||
@ -162,7 +159,7 @@ func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
|||||||
}
|
}
|
||||||
rawHttpOptions.Timeout = options.Options.GetTimeouts().HttpTimeout
|
rawHttpOptions.Timeout = options.Options.GetTimeouts().HttpTimeout
|
||||||
rawHttpClient = rawhttp.NewClient(rawHttpOptions)
|
rawHttpClient = rawhttp.NewClient(rawHttpOptions)
|
||||||
}
|
})
|
||||||
return rawHttpClient
|
return rawHttpClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user