You've already forked cpp-httplib
							
							Fix #2097
This commit is contained in:
		
							
								
								
									
										20
									
								
								httplib.h
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								httplib.h
									
									
									
									
									
								
							@@ -2951,7 +2951,7 @@ inline std::string decode_url(const std::string &s,
 | 
			
		||||
 | 
			
		||||
inline std::string file_extension(const std::string &path) {
 | 
			
		||||
  std::smatch m;
 | 
			
		||||
  static auto re = std::regex("\\.([a-zA-Z0-9]+)$");
 | 
			
		||||
  thread_local auto re = std::regex("\\.([a-zA-Z0-9]+)$");
 | 
			
		||||
  if (std::regex_search(path, m, re)) { return m[1].str(); }
 | 
			
		||||
  return std::string();
 | 
			
		||||
}
 | 
			
		||||
@@ -5013,7 +5013,7 @@ public:
 | 
			
		||||
            file_.content_type =
 | 
			
		||||
                trim_copy(header.substr(str_len(header_content_type)));
 | 
			
		||||
          } else {
 | 
			
		||||
            static const std::regex re_content_disposition(
 | 
			
		||||
            thread_local const std::regex re_content_disposition(
 | 
			
		||||
                R"~(^Content-Disposition:\s*form-data;\s*(.*)$)~",
 | 
			
		||||
                std::regex_constants::icase);
 | 
			
		||||
 | 
			
		||||
@@ -5036,7 +5036,7 @@ public:
 | 
			
		||||
              it = params.find("filename*");
 | 
			
		||||
              if (it != params.end()) {
 | 
			
		||||
                // Only allow UTF-8 encoding...
 | 
			
		||||
                static const std::regex re_rfc5987_encoding(
 | 
			
		||||
                thread_local const std::regex re_rfc5987_encoding(
 | 
			
		||||
                    R"~(^UTF-8''(.+?)$)~", std::regex_constants::icase);
 | 
			
		||||
 | 
			
		||||
                std::smatch m2;
 | 
			
		||||
@@ -5201,7 +5201,7 @@ inline std::string random_string(size_t length) {
 | 
			
		||||
  constexpr const char data[] =
 | 
			
		||||
      "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 | 
			
		||||
 | 
			
		||||
  static thread_local std::mt19937 engine([]() {
 | 
			
		||||
  thread_local auto engine([]() {
 | 
			
		||||
    // std::random_device might actually be deterministic on some
 | 
			
		||||
    // platforms, but due to lack of support in the c++ standard library,
 | 
			
		||||
    // doing better requires either some ugly hacks or breaking portability.
 | 
			
		||||
@@ -5723,7 +5723,7 @@ inline bool parse_www_authenticate(const Response &res,
 | 
			
		||||
                                   bool is_proxy) {
 | 
			
		||||
  auto auth_key = is_proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
 | 
			
		||||
  if (res.has_header(auth_key)) {
 | 
			
		||||
    static auto re = std::regex(R"~((?:(?:,\s*)?(.+?)=(?:"(.*?)"|([^,]*))))~");
 | 
			
		||||
    thread_local auto re = std::regex(R"~((?:(?:,\s*)?(.+?)=(?:"(.*?)"|([^,]*))))~");
 | 
			
		||||
    auto s = res.get_header_value(auth_key);
 | 
			
		||||
    auto pos = s.find(' ');
 | 
			
		||||
    if (pos != std::string::npos) {
 | 
			
		||||
@@ -5807,7 +5807,7 @@ inline void hosted_at(const std::string &hostname,
 | 
			
		||||
inline std::string append_query_params(const std::string &path,
 | 
			
		||||
                                       const Params ¶ms) {
 | 
			
		||||
  std::string path_with_query = path;
 | 
			
		||||
  const static std::regex re("[^?]+\\?.*");
 | 
			
		||||
  thread_local const std::regex re("[^?]+\\?.*");
 | 
			
		||||
  auto delm = std::regex_match(path, re) ? '&' : '?';
 | 
			
		||||
  path_with_query += delm + detail::params_to_query_str(params);
 | 
			
		||||
  return path_with_query;
 | 
			
		||||
@@ -6581,7 +6581,7 @@ inline bool Server::parse_request_line(const char *s, Request &req) const {
 | 
			
		||||
    if (count != 3) { return false; }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static const std::set<std::string> methods{
 | 
			
		||||
  thread_local const std::set<std::string> methods{
 | 
			
		||||
      "GET",     "HEAD",    "POST",  "PUT",   "DELETE",
 | 
			
		||||
      "CONNECT", "OPTIONS", "TRACE", "PATCH", "PRI"};
 | 
			
		||||
 | 
			
		||||
@@ -7581,9 +7581,9 @@ inline bool ClientImpl::read_response_line(Stream &strm, const Request &req,
 | 
			
		||||
  if (!line_reader.getline()) { return false; }
 | 
			
		||||
 | 
			
		||||
#ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
 | 
			
		||||
  const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r?\n");
 | 
			
		||||
  thread_local const std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r?\n");
 | 
			
		||||
#else
 | 
			
		||||
  const static std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r\n");
 | 
			
		||||
  thread_local const  std::regex re("(HTTP/1\\.[01]) (\\d{3})(?: (.*?))?\r\n");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  std::cmatch m;
 | 
			
		||||
@@ -7815,7 +7815,7 @@ inline bool ClientImpl::redirect(Request &req, Response &res, Error &error) {
 | 
			
		||||
  auto location = res.get_header_value("location");
 | 
			
		||||
  if (location.empty()) { return false; }
 | 
			
		||||
 | 
			
		||||
  const static std::regex re(
 | 
			
		||||
  thread_local const std::regex re(
 | 
			
		||||
      R"((?:(https?):)?(?://(?:\[([a-fA-F\d:]+)\]|([^:/?#]+))(?::(\d+))?)?([^?#]*)(\?[^#]*)?(?:#.*)?)");
 | 
			
		||||
 | 
			
		||||
  std::smatch m;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user