@@ -2951,7 +2951,7 @@ inline std::string decode_url(const std::string &s,
2951
2951
2952
2952
inline std::string file_extension (const std::string &path) {
2953
2953
std::smatch m;
2954
- static auto re = std::regex (" \\ .([a-zA-Z0-9]+)$" );
2954
+ thread_local auto re = std::regex (" \\ .([a-zA-Z0-9]+)$" );
2955
2955
if (std::regex_search (path, m, re)) { return m[1 ].str (); }
2956
2956
return std::string ();
2957
2957
}
@@ -5013,7 +5013,7 @@ class MultipartFormDataParser {
5013
5013
file_.content_type =
5014
5014
trim_copy (header.substr (str_len (header_content_type)));
5015
5015
} else {
5016
- static const std::regex re_content_disposition (
5016
+ thread_local const std::regex re_content_disposition (
5017
5017
R"~( ^Content-Disposition:\s*form-data;\s*(.*)$)~" ,
5018
5018
std::regex_constants::icase);
5019
5019
@@ -5036,7 +5036,7 @@ class MultipartFormDataParser {
5036
5036
it = params.find (" filename*" );
5037
5037
if (it != params.end ()) {
5038
5038
// Only allow UTF-8 encoding...
5039
- static const std::regex re_rfc5987_encoding (
5039
+ thread_local const std::regex re_rfc5987_encoding (
5040
5040
R"~( ^UTF-8''(.+?)$)~" , std::regex_constants::icase);
5041
5041
5042
5042
std::smatch m2;
@@ -5201,7 +5201,7 @@ inline std::string random_string(size_t length) {
5201
5201
constexpr const char data[] =
5202
5202
" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
5203
5203
5204
- static thread_local std::mt19937 engine ([]() {
5204
+ thread_local auto engine ([]() {
5205
5205
// std::random_device might actually be deterministic on some
5206
5206
// platforms, but due to lack of support in the c++ standard library,
5207
5207
// doing better requires either some ugly hacks or breaking portability.
@@ -5723,7 +5723,7 @@ inline bool parse_www_authenticate(const Response &res,
5723
5723
bool is_proxy) {
5724
5724
auto auth_key = is_proxy ? " Proxy-Authenticate" : " WWW-Authenticate" ;
5725
5725
if (res.has_header (auth_key)) {
5726
- static auto re = std::regex (R"~( (?:(?:,\s*)?(.+?)=(?:"(.*?)"|([^,]*))))~" );
5726
+ thread_local auto re = std::regex (R"~( (?:(?:,\s*)?(.+?)=(?:"(.*?)"|([^,]*))))~" );
5727
5727
auto s = res.get_header_value (auth_key);
5728
5728
auto pos = s.find (' ' );
5729
5729
if (pos != std::string::npos) {
@@ -5807,7 +5807,7 @@ inline void hosted_at(const std::string &hostname,
5807
5807
inline std::string append_query_params (const std::string &path,
5808
5808
const Params ¶ms) {
5809
5809
std::string path_with_query = path;
5810
- const static std::regex re (" [^?]+\\ ?.*" );
5810
+ thread_local const std::regex re (" [^?]+\\ ?.*" );
5811
5811
auto delm = std::regex_match (path, re) ? ' &' : ' ?' ;
5812
5812
path_with_query += delm + detail::params_to_query_str (params);
5813
5813
return path_with_query;
@@ -6581,7 +6581,7 @@ inline bool Server::parse_request_line(const char *s, Request &req) const {
6581
6581
if (count != 3 ) { return false ; }
6582
6582
}
6583
6583
6584
- static const std::set<std::string> methods{
6584
+ thread_local const std::set<std::string> methods{
6585
6585
" GET" , " HEAD" , " POST" , " PUT" , " DELETE" ,
6586
6586
" CONNECT" , " OPTIONS" , " TRACE" , " PATCH" , " PRI" };
6587
6587
@@ -7581,9 +7581,9 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req,
7581
7581
if (!line_reader.getline ()) { return false ; }
7582
7582
7583
7583
#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
7584
- const static std::regex re (" (HTTP/1\\ .[01]) (\\ d{3})(?: (.*?))?\r ?\n " );
7584
+ thread_local const std::regex re (" (HTTP/1\\ .[01]) (\\ d{3})(?: (.*?))?\r ?\n " );
7585
7585
#else
7586
- const static std::regex re (" (HTTP/1\\ .[01]) (\\ d{3})(?: (.*?))?\r\n " );
7586
+ thread_local const std::regex re (" (HTTP/1\\ .[01]) (\\ d{3})(?: (.*?))?\r\n " );
7587
7587
#endif
7588
7588
7589
7589
std::cmatch m;
@@ -7815,7 +7815,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
7815
7815
auto location = res.get_header_value (" location" );
7816
7816
if (location.empty ()) { return false ; }
7817
7817
7818
- const static std::regex re (
7818
+ thread_local const std::regex re (
7819
7819
R"( (?:(https?):)?(?://(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\?[^#]*)?(?:#.*)?)" );
7820
7820
7821
7821
std::smatch m;
0 commit comments