net-cpp
..
C++11 library for networking purposes
header.h
Go to the documentation of this file.
1
/*
2
* Copyright © 2013 Canonical Ltd.
3
*
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3,
6
* as published by the Free Software Foundation.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
12
*
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
17
*/
18
#ifndef CORE_NET_HTTP_HEADER_H_
19
#define CORE_NET_HTTP_HEADER_H_
20
21
#include <
core/net/visibility.h
>
22
23
#include <map>
24
#include <memory>
25
#include <set>
26
#include <string>
27
#include <functional>
28
29
namespace
core
30
{
31
namespace
net
32
{
33
namespace
http
34
{
38
class
CORE_NET_DLL_PUBLIC
Header
39
{
40
public
:
51
static
std::string
canonicalize_key
(
const
std::string& key);
52
53
virtual
~Header
() =
default
;
54
60
virtual
bool
has
(
const
std::string& key,
const
std::string& value)
const
;
61
66
virtual
bool
has
(
const
std::string& key)
const
;
67
71
virtual
void
add
(
const
std::string& key,
const
std::string& value);
72
76
virtual
void
remove
(
const
std::string& key);
77
81
virtual
void
remove
(
const
std::string& key,
const
std::string& value);
82
86
virtual
void
set
(
const
std::string& key,
const
std::string& value);
87
91
virtual
void
enumerate
(
const
std::function<
void
(
const
std::string&,
const
std::set<std::string>&)>& enumerator)
const
;
92
93
private
:
95
std::map<std::string, std::set<std::string>> fields;
97
};
98
}
99
}
100
}
101
102
#endif
// CORE_NET_HTTP_HEADER_H_
core::net::http::Header
The Header class encapsulates the headers of an HTTP request/response.
Definition:
header.h:39
core::net::http::Header::enumerate
virtual void enumerate(const std::function< void(const std::string &, const std::set< std::string > &)> &enumerator) const
enumerate iterates over the known fields and invokes the given enumerator for each of them.
core::net::http::Header::has
virtual bool has(const std::string &key) const
has checks if the header contains any entry for the given key.
core::net::http::Header::add
virtual void add(const std::string &key, const std::string &value)
add adds the given value for the given key to the header.
core::net::http::Header::has
virtual bool has(const std::string &key, const std::string &value) const
has checks if the header contains an entry for the given key with the given value.
core::net::http::Header::remove
virtual void remove(const std::string &key, const std::string &value)
remove erases the given value for the given key from the header.
core::net::http::Header::~Header
virtual ~Header()=default
core::net::http::Header::set
virtual void set(const std::string &key, const std::string &value)
set assigns the given value to the entry with key 'key' and replaces any previous value.
core::net::http::Header::canonicalize_key
static std::string canonicalize_key(const std::string &key)
canonicalize_key returns the canonical form of the header key 'key'.
core::net::http::Header::remove
virtual void remove(const std::string &key)
remove erases all values for the given key from the header.
core
Definition:
location.h:24
visibility.h
CORE_NET_DLL_PUBLIC
#define CORE_NET_DLL_PUBLIC
Definition:
visibility.h:25
include
core
net
http
header.h
Generated on Wed Jul 26 2023 02:12:04 for net-cpp by
1.9.4