FIX: thread safe of http extra headers
Change-Id: I6ffa424be7ccb6abd78a66cc8be535f038b05469 Jira: none
This commit is contained in:
parent
fdcd6085d2
commit
5cf0871ea1
|
@ -84,6 +84,7 @@ struct CurlGlobalInit
|
|||
std::unique_ptr<CurlGlobalInit> CurlGlobalInit::instance;
|
||||
|
||||
std::map<std::string, std::string> extra_headers;
|
||||
std::mutex g_mutex;
|
||||
|
||||
struct Http::priv
|
||||
{
|
||||
|
@ -470,6 +471,7 @@ void Http::priv::http_perform()
|
|||
|
||||
Http::Http(const std::string &url) : p(new priv(url)) {
|
||||
|
||||
std::lock_guard<std::mutex> l(g_mutex);
|
||||
for (auto it = extra_headers.begin(); it != extra_headers.end(); it++)
|
||||
this->header(it->first, it->second);
|
||||
}
|
||||
|
@ -740,6 +742,7 @@ Http Http::del(std::string url)
|
|||
|
||||
void Http::set_extra_headers(std::map<std::string, std::string> headers)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(g_mutex);
|
||||
extra_headers.swap(headers);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue