Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
url_utils.h
Go to the documentation of this file.
1
15 #pragma once
16
17 #include <string>
18 #include <unordered_map>
19 #include <sstream>
20
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);
31 }
32
41 std::string urlDecode(const std::string &src);
42
52 std::unordered_multimap<std::string, std::string> parseUrlEncoded(const std::string& data);
53
54
63 std::string getClientIpFromSocket(int sock);
64
73 std::string getMimeType(const std::string& filePath);
74
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").
Definition url_utils.cpp:28
std::string trim(const std::string &s)
Trim whitespace from the beginning and end of a string.
Definition url_utils.h:27
std::unordered_multimap< std::string, std::string > parseUrlEncoded(const std::string &data)
Parse a URL-encoded key-value string into a map.
Definition url_utils.cpp:67