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 
28 namespace core
29 {
30 namespace net
31 {
32 namespace http
33 {
38 {
39 public:
50  static std::string canonicalize_key(const std::string& key);
51 
52  virtual ~Header() = default;
53 
59  virtual bool has(const std::string& key, const std::string& value) const;
60 
65  virtual bool has(const std::string& key) const;
66 
70  virtual void add(const std::string& key, const std::string& value);
71 
75  virtual void remove(const std::string& key);
76 
80  virtual void remove(const std::string& key, const std::string& value);
81 
85  virtual void set(const std::string& key, const std::string& value);
86 
90  virtual void enumerate(const std::function<void(const std::string&, const std::set<std::string>&)>& enumerator) const;
91 
92 private:
94  std::map<std::string, std::set<std::string>> fields;
96 };
97 }
98 }
99 }
100 
101 #endif // CORE_NET_HTTP_HEADER_H_
Definition: location.h:23
The Header class encapsulates the headers of an HTTP request/response.
Definition: header.h:37
#define CORE_NET_DLL_PUBLIC
Definition: visibility.h:25