Implementation of URL utility functions for decoding, parsing, and MIME type detection. More...
#include "http/url_utils.h"
#include <sstream>
#include <lwip/sockets.h>
#include <lwip/ip_addr.h>
#include <lwip/memp.h>
#include <string>
#include <algorithm>
#include <cctype>
#include "network/Tcp.h"
Go to the source code of this file.
Functions | |
std::string | urlDecode (const std::string &src) |
std::unordered_multimap< std::string, std::string > | parseUrlEncoded (const std::string &data) |
std::string | getClientIpFromTcp (Tcp *tcp) |
Get the client IP address from a socket. | |
std::string | getMimeType (const std::string &filePath) |
Part of the PicoFramework HTTP server. This module provides functions for URL decoding, parsing URL-encoded form data, extracting client IP addresses from sockets, and determining MIME types based on file extensions.
Definition in file url_utils.cpp.
std::string getClientIpFromTcp | ( | Tcp * | tcp | ) |
Uses lwIP's lwip_getpeername()
to extract the IP address of the remote peer.
sock | The socket file descriptor. |
Definition at line 88 of file url_utils.cpp.
References Tcp::getSocketFd().
std::string getMimeType | ( | const std::string & | filePath | ) |
Get the MIME type based on a file path's extension.
Get the MIME type based on a file path's extension.
Definition at line 105 of file url_utils.cpp.
Referenced by FileHandler::serveFile().
std::unordered_multimap< std::string, std::string > parseUrlEncoded | ( | const std::string & | data | ) |
Parse a URL-encoded key-value string into a map.
Parse a URL-encoded key-value string into a map.
Definition at line 67 of file url_utils.cpp.
References urlDecode().
Referenced by HttpRequest::getFormParams(), and HttpRequest::getQueryParams().
std::string urlDecode | ( | const std::string & | src | ) |
Decode a URL-encoded string (e.g., "a%20b+c" -> "a b c").
Decode a URL-encoded string (e.g., "a%20b+c" -> "a b c").
Definition at line 28 of file url_utils.cpp.
Referenced by HttpFileserver::handle_static_request(), Router::handleRequest(), and parseUrlEncoded().