18 #include <unordered_map>
27 inline std::string
trim(
const std::string& s) {
28 size_t start = s.find_first_not_of(
" \t\r\n");
29 size_t end = s.find_last_not_of(
" \t\r\n");
30 return (start == std::string::npos) ?
"" : s.substr(start, end - start + 1);
41 std::string
urlDecode(
const std::string &src);
52 std::unordered_multimap<std::string, std::string>
parseUrlEncoded(
const std::string& data);
73 std::string
getMimeType(
const std::string& filePath);
std::string getMimeType(const std::string &filePath)
Get the MIME type based on a file path's extension.
std::string getClientIpFromSocket(int sock)
Get the client IP address from a socket.
std::string urlDecode(const std::string &src)
Decode a URL-encoded string (e.g., "a%20b+c" -> "a b c").
std::string trim(const std::string &s)
Trim whitespace from the beginning and end of a string.
std::unordered_multimap< std::string, std::string > parseUrlEncoded(const std::string &data)
Parse a URL-encoded key-value string into a map.