Merge pull request #343 from projectdiscovery/bugfix-connection-header

connection header logic fix
dev
bauthard 2020-10-07 17:20:15 +05:30 committed by GitHub
commit 551d0307d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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