FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
libhttpserver/src/httpserver/http_utils_helpers.hpp at master · etr/libhttpserver · GitHub
etr
/
libhttpserver
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
190
Star
950
Code
Issues
7
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
libhttpserver
/
src
/
httpserver
/
http_utils_helpers.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
108 lines (91 loc) · 3.78 KB
Breadcrumbs
libhttpserver
/
src
/
httpserver
/
http_utils_helpers.hpp
Copy path
File metadata and controls
108 lines (91 loc) · 3.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
This file is part of libhttpserver
Copyright (C) 2011-2019 Sebastiano Merlino
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
#
if
!defined (_HTTPSERVER_HPP_INSIDE_) && !defined (HTTPSERVER_COMPILATION)
#
error
"Only <httpserver.hpp> or <httpserverpp> can be included directly."
#
endif
//
http_utils_helpers.hpp -- free-function helpers in namespace
//
httpserver::http (sockaddr -> string/port, header/arg map dumps, URL
//
unescape, file loading).
//
//
Carved out of httpserver/http_utils.hpp to keep that header
//
under the project per-file line-count ceiling (FILE_LOC_MAX in
//
scripts/check-file-size.sh). Included from the bottom of http_utils.hpp
//
after the types these declarations reference (header_view_map /
//
header_map / arg_view_map / unescaper_ptr) are defined; not intended to
//
be included on its own.
#
ifndef
SRC_HTTPSERVER_HTTP_UTILS_HELPERS_HPP_
#
define
SRC_HTTPSERVER_HTTP_UTILS_HELPERS_HPP_
#
include
<
stddef.h
>
#
include
<
stdint.h
>
#
include
<
iosfwd
>
#
include
<
string
>
namespace
httpserver
{
namespace
http
{
/*
*
* Method used to get an ip in form of string from a sockaddr structure.
*
* The buffer length is computed internally from the address family; the
* v1 `maxlen` parameter was removed in v2.0.
*
* @param sa The sockaddr object to find the ip address from.
* @return string containing the ip address.
*
*/
std::string
get_ip_str
(
const
struct
sockaddr
*sa);
/*
*
* Method used to get a port from a sockaddr
* @param sa The sockaddr object to find the port from
* @return short representing the port
*
*/
uint16_t
get_port
(
const
struct
sockaddr
* sa);
/*
*
* Method to output the contents of a headers map to a std::ostream
* @param os The ostream
* @param prefix Prefix to identify the map
* @param map
*
*/
void
dump_header_map
(std::ostream& os,
const
std::string& prefix,
const
http::header_view_map& map);
/*
*
* Overload that accepts the owning header_map directly, avoiding an O(n)
* copy into a temporary header_view_map. Preferred for diagnostic output
* (operator<<) where the source map is immediately available.
* @param os The ostream
* @param prefix Prefix to identify the map
* @param map
*
*/
void
dump_header_map
(std::ostream& os,
const
std::string& prefix,
const
http::header_map& map);
/*
*
* Method to output the contents of an arguments map to a std::ostream
* @param os The ostream
* @param prefix Prefix to identify the map
* @param map
*
*/
void
dump_arg_map
(std::ostream& os,
const
std::string& prefix,
const
http::arg_view_map& map);
/*
*
* Process escape sequences ('+'=space, %HH) Updates val in place; the
* result should be UTF-8 encoded and cannot be larger than the input.
* The result must also still be 0-terminated.
*
* @param val the string to unescape
* @return length of the resulting val (strlen(val) maybe
* shorter afterwards due to elimination of escape sequences)
*/
size_t
http_unescape
(std::string* val);
const
std::string
load_file
(
const
std::string& filename);
size_t
base_unescaper
(std::string*, unescaper_ptr unescaper);
}
//
namespace http
}
//
namespace httpserver
#
endif
//
SRC_HTTPSERVER_HTTP_UTILS_HELPERS_HPP_
Back
|
FazBrowse Home
|
New Git URL