SNode.C
Loading...
Searching...
No Matches
http_utils.h
Go to the documentation of this file.
1/*
2 * snode.c - a slim toolkit for network communication
3 * Copyright (C) 2020, 2021 Volker Christian <me@vchrist.at>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef WEB_HTTP_UTILS_H
20#define WEB_HTTP_UTILS_H
21
22#ifndef DOXYGEN_SHOULD_SKIP_THIS
23
24namespace web::http {
25 class CookieOptions;
26 template <typename ValueT>
27 class CiStringMap;
28} // namespace web::http
29
30#include <string>
31#include <time.h>
32#include <utility>
33#include <vector>
34
35// IWYU pragma: no_include <bits/types/struct_tm.h>
36
37#endif /* DOXYGEN_SHOULD_SKIP_THIS */
38
39namespace httputils {
40
41 std::string url_decode(const std::string& text);
42
43 std::string url_encode(const std::string& text);
44
45 std::string& str_trimm(std::string& text);
46
47 std::pair<std::string, std::string> str_split(const std::string& base, char c_middle);
48
49 std::pair<std::string, std::string> str_split_last(const std::string& base, char c_middle);
50
51 std::string to_http_date(struct tm* tm = nullptr);
52
53 struct tm from_http_date(const std::string& http_date);
54
55 std::string file_mod_http_date(const std::string& filePath);
56
58
59 std::string toString(const std::string& method,
60 const std::string& url,
61 const std::string& version,
62 const web::http::CiStringMap<std::string>& queries,
63 const web::http::CiStringMap<std::string>& header,
64 const web::http::CiStringMap<std::string>& cookies,
65 const std::vector<char>& body);
66
67 std::string toString(const std::string& version,
68 const std::string& statusCode,
69 const std::string& reason,
70 const web::http::CiStringMap<std::string>& header,
71 const web::http::CiStringMap<web::http::CookieOptions>& cookies,
72 const std::vector<char>& body);
73
74} // namespace httputils
75
76#endif // WEB_HTTP_UTILS_H
std::string to_http_date(struct tm *tm)
std::string toString(const std::string &version, const std::string &statusCode, const std::string &reason, const web::http::CiStringMap< std::string > &header, const web::http::CiStringMap< web::http::CookieOptions > &cookies, const std::vector< char > &body)
std::string url_encode(const std::string &text)
std::string file_mod_http_date(const std::string &filePath)
std::string::iterator to_lower(std::string &string)
std::pair< std::string, std::string > str_split_last(const std::string &base, char c_middle)
std::string url_decode(const std::string &text)
std::pair< std::string, std::string > str_split(const std::string &base, char c_middle)
std::string & str_trimm(std::string &text)
std::string toString(const std::string &method, const std::string &url, const std::string &version, const web::http::CiStringMap< std::string > &queries, const web::http::CiStringMap< std::string > &header, const web::http::CiStringMap< std::string > &cookies, const std::vector< char > &body)