connection header logic fix

dev
Mzack9999 2020-10-06 20:39:42 +02:00
parent e765b29bff
commit ec497696ee
1 changed files with 7 additions and 2 deletions

View File

@ -240,8 +240,6 @@ func (r *BulkHTTPRequest) handleRawWithPaylods(ctx context.Context, raw, baseURL
}
func (r *BulkHTTPRequest) fillRequest(req *http.Request, values map[string]interface{}) (*retryablehttp.Request, error) {
setHeader(req, "Connection", "close")
req.Close = true
replacer := newReplacer(values)
// Check if the user requested a request body
@ -254,6 +252,13 @@ func (r *BulkHTTPRequest) fillRequest(req *http.Request, values map[string]inter
req.Header[header] = []string{replacer.Replace(value)}
}
// if the user specified a Connection header we don't alter it
if req.Header.Get("Connection") == "" {
// Otherwise we set it to "Connection: close" - The instruction is redundant, but it ensures that internally net/http don't miss the header/internal flag
setHeader(req, "Connection", "close")
req.Close = true
}
setHeader(req, "User-Agent", "Nuclei - Open-source project (github.com/projectdiscovery/nuclei)")
// raw requests are left untouched