Skip to content

Commit

Permalink
fix: concurrent writes to headers of http_response (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 authored Feb 22, 2024
1 parent d944d18 commit ed4f758
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions inputs/http_response/http_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (ins *Instance) Init() error {
if ins.HTTPCommonConfig.Headers == nil {
ins.HTTPCommonConfig.Headers = make(map[string]string)
}
// compatible with old config
for i := 0; i < len(ins.Headers); i += 2 {
ins.HTTPCommonConfig.Headers[ins.Headers[i]] = ins.Headers[i+1]
}
if len(ins.ExpectResponseRegularExpression) > 0 {
ins.regularExpression = regexp.MustCompile(ins.ExpectResponseRegularExpression)
}
Expand Down Expand Up @@ -241,11 +245,6 @@ func (ins *Instance) httpGather(target string) (map[string]string, map[string]in
if err != nil {
return nil, nil, err
}

// compatible with old config
for i := 0; i < len(ins.Headers); i += 2 {
ins.HTTPCommonConfig.Headers[ins.Headers[i]] = ins.Headers[i+1]
}
ins.SetHeaders(request)

// Start Timer
Expand Down

0 comments on commit ed4f758

Please sign in to comment.