mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Clone header before creating exporter HTTP request
Behind http.Header is just a map and it's not safe for concurrent use. Before this change, a panic might have occurred when doing asynchronous HTTP exports (applies to both *http_post and *http_json_map exporters). Cloning the header before adding it to the HTTP request has fixed this issue. Slightly improved the test that found this data race.
This commit is contained in:
committed by
Dan Christian Bogos
parent
c7e1f8f036
commit
29f58debc9
@@ -96,7 +96,7 @@ func (httpEE *HTTPjsonMapEE) GetMetrics() *utils.SafeMapStorage { return httpEE.
|
||||
func (httpEE *HTTPjsonMapEE) PrepareMap(mp *utils.CGREvent) (any, error) {
|
||||
body, err := json.Marshal(mp.Event)
|
||||
return &HTTPPosterRequest{
|
||||
Header: httpEE.hdr,
|
||||
Header: httpEE.hdr.Clone(),
|
||||
Body: body,
|
||||
}, err
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (httpEE *HTTPjsonMapEE) PrepareOrderMap(mp *utils.OrderedNavigableMap) (any
|
||||
}
|
||||
body, err := json.Marshal(valMp)
|
||||
return &HTTPPosterRequest{
|
||||
Header: httpEE.hdr,
|
||||
Header: httpEE.hdr.Clone(),
|
||||
Body: body,
|
||||
}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user